Jump to content




GUI.API | Simple & Powerful Buttons,Dialogue Boxes, Text-boxes, and More!

api lua computer

  • You cannot reply to this topic
49 replies to this topic

#21 account.username

  • Members
  • 20 posts

Posted 13 June 2014 - 01:05 AM

@Hbomb_79 you just need to have the buttons action set as a function.

button = gui.createButotn( "Button", function() doSomething() end )
button:trigger()


#22 newcat

  • Members
  • 43 posts
  • LocationStuttgart, Germany

Posted 13 June 2014 - 05:20 PM

Just found another bug: If you use multiple dialogboxes in one program, after clicking "ok" in one dBox, in each following box you can click whereever you want and it will still continue.

Looking at the code I noticed that ret is not local, so everytime you call box:draw(), ret will have the value of the last dBox.

I didn't test it with y/n-boxes, but there will be the same problem. I solved it with declaring ret as local at the start of the draw-function, so it will be deleted after the function finished:
function Boxs:draw( x,y,width,color,bcolor,tcolor )
  local ret = nil
  ... --all the other stuff here
end


#23 account.username

  • Members
  • 20 posts

Posted 13 June 2014 - 07:52 PM

@newcat Thanks thats fixed!

#24 hbomb79

  • Members
  • 352 posts
  • LocationOrewa, New Zealand

Posted 16 June 2014 - 03:44 AM

Can you explain that button:trigger() i want it so i can have a menu that displays several buttons, when i click on one it clears the screen and loads a function ive already made... the function is called bulkHead() how would i do this?

#25 BytePointer

  • Members
  • 17 posts

Posted 19 June 2014 - 06:12 AM

WOW, this is VERY useful! Thanks, I suck at GUIs!

#26 hbomb79

  • Members
  • 352 posts
  • LocationOrewa, New Zealand

Posted 19 June 2014 - 09:11 AM

Can someone help me out, this is what im having issues with, i have NO idea how to use this api...

this is the code.... It crashes and turns red without even clicking the button as well....???

os.loadAPI("/api")
function hi()
  print "Hi"
end
button = api.createButton ("button", fucntion() hi() end)
button:draw(1,1 5, colors.green, colors.white)
button:toggle(colors.red,4)
button:trigger()

It then gives me this error "api:70: attempt to index ? (a nil value)"

#27 account.username

  • Members
  • 20 posts

Posted 19 June 2014 - 07:26 PM

@Hbomb_79

Change:
os.loadAPI("/api")

To:
os.loadAPI("api")

#28 Lignum

  • Members
  • 558 posts

Posted 19 June 2014 - 07:33 PM

View Postaccount.username, on 19 June 2014 - 07:26 PM, said:

@Hbomb_79

Change:
os.loadAPI("/api")

To:
os.loadAPI("api")

That wouldn't make a difference. The error occurs in the API, which means it's been loaded.

#29 newcat

  • Members
  • 43 posts
  • LocationStuttgart, Germany

Posted 20 June 2014 - 10:51 PM

There is a spell mistake. It needs to be

function() hi() end

You have written fucntion().

#30 hbomb79

  • Members
  • 352 posts
  • LocationOrewa, New Zealand

Posted 30 June 2014 - 02:21 AM

Oh wow, what a silly mistake... Thanks

#31 gknova61

  • Members
  • 74 posts

Posted 30 June 2014 - 09:17 AM

I just tried buttons (first & last thing I tried), and I got this error:
Just downloaded the API so latest version.
[string "gui"]:70: attempt to index a nil value after running the following code
os.loadAPI("gui")
button = gui.createButton(  "button", function() print("Hello World!") end ) --#This creates a new button with a function that when triggered will print "Hello World!"

button:draw( 1,1, 5, colors.green, colors.white ) -- #This draws the button at (1,1) with a width of 5. The first color is what the buttons color will be and the second color is the text color

button:toggle( colors.red,4) --#This toggles the buttons color to red for 4 seconds (If you leave the second argument as nil it will just toggle the button)

button:trigger() --#This triggers the buttons function

gui.detect( 1,3,true ) --#this checks an array of all the buttons you've defined and returns the name of the button. If you also set the third argument to true it will trigger that buttons action
It errors on button:trigger()

Edited by gknova61, 30 June 2014 - 09:17 AM.


#32 newcat

  • Members
  • 43 posts
  • LocationStuttgart, Germany

Posted 08 August 2014 - 01:52 AM

I started to work on my old GUI project again and fixed the problems with the textboxes I mentioned in one of my older posts. Here is the new version:

Spoiler

I found no way to pull an event like "key_up" therefore you can just toggle shift at the moment. Maybe that will be implemented in a later version of CC...
I hope you update your API so all the people who want to work with that awesome API have that fix without having to manually paste it into their version.

#33 NikolaiM

  • New Members
  • 1 posts

Posted 13 August 2014 - 10:13 AM

Trying to make a power monitor, but every time i run the program the bar shows up all wierd looking(not working proberly)

http://pastebin.com/NiQJJdUU

#34 TommieIV

  • Members
  • 7 posts

Posted 19 August 2014 - 09:54 PM

Would anybody do a tutorial video? I kinna need one! Or answer this: how do I use the button trigger function?

#35 newcat

  • Members
  • 43 posts
  • LocationStuttgart, Germany

Posted 20 August 2014 - 01:46 PM

View PostTommieIV, on 19 August 2014 - 09:54 PM, said:

Would anybody do a tutorial video? I kinna need one! Or answer this: how do I use the button trigger function?
I will probably do one in a few days.

#36 newcat

  • Members
  • 43 posts
  • LocationStuttgart, Germany

Posted 24 August 2014 - 02:29 AM

View PostNikolaiM, on 13 August 2014 - 10:13 AM, said:

Trying to make a power monitor, but every time i run the program the bar shows up all wierd looking(not working proberly)

http://pastebin.com/NiQJJdUU
What data do you get from the sensor? Some example values would be cool

#37 newcat

  • Members
  • 43 posts
  • LocationStuttgart, Germany

Posted 25 August 2014 - 11:32 PM

View PostTommieIV, on 19 August 2014 - 09:54 PM, said:

Would anybody do a tutorial video? I kinna need one! Or answer this: how do I use the button trigger function?
Here is it: https://www.youtube....h?v=-oXDm92KZRc

#38 account.username

  • Members
  • 20 posts

Posted 27 August 2014 - 01:22 AM

@newcat THANK YOU SO MUCH!!!!!!!!!!!!

#39 Mackan90096

  • Signature Abuser
  • 518 posts
  • LocationIn my basement.

Posted 29 August 2014 - 03:52 PM

Looks, really good, I'm going to use this with my OS. Am I allowed to upload this to github and redistrubute it with the download of my OS if I give full credit of it to you ?

#40 Rougeminner

  • Members
  • 151 posts

Posted 04 September 2014 - 07:16 PM

I am sorry for a "delayed" reply acounts.username. Your script kinda reminded of applescript that is why i asked but great api going to use it for a OS. Since i have been to busy to check recently is this api compatibld with PDA's





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users