This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
grand_mind1's profile picture

Button Api Help

Started by grand_mind1, 22 September 2013 - 01:03 AM
grand_mind1 #1
Posted 22 September 2013 - 03:03 AM
Button API:
http://pastebin.com/TmCR7bWX
Current code:
http://pastebin.com/vad3vses

I'm having problems with the sixth line where I say what the title is and what the color for the title should be. When I try the run the current code I get this error:

btn:55: Expected Number
This is where the computer sets the text color for the title. I've no idea why this would happen because I tell it to set the color to colors.white on line six.
Help is appreciated!
Thanks! :D/>
Lyqyd #2
Posted 22 September 2013 - 03:19 AM
Line 65 calls title without specifying the color, which calls centerText without specifying a color. The error is thrown when centerText tries to set the text color to nil.
grand_mind1 #3
Posted 22 September 2013 - 03:43 AM
Thanks! Also, in the fillTable function, when I tell it what function to run when it is clicked, is there any way to be able to have parameters passed to the function that it runs? If this requires more explanation please tell me.
Apfeldstrudel #4
Posted 22 September 2013 - 04:23 AM
I'm interested in an answer for this too.
Lyqyd #5
Posted 22 September 2013 - 01:22 PM
Yes, if they are known beforehand. Simply create an anonymous function to call the actual desired function:


function() return shell.run("argument") end

Notice that all this does is tail call another function with some arguments, but doesn't need any arguments passed to it.