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

[lua][api]Buttonapi not drawing correct.

Started by Goof, 16 April 2013 - 03:54 AM
Goof #1
Posted 16 April 2013 - 05:54 AM
Hello Everyone!


I am working on an OS, and im trying to make a button API. but…
kinda "button:51: Expected number, number" isnt the best result for me..
(Pastebin)



I hope to see someone to help me!



Thanks in advance.
remiX #2
Posted 16 April 2013 - 05:57 AM
EDIT: Nevermind, big derp

How are you calling the function draw()
Goof #3
Posted 16 April 2013 - 06:22 AM
with button.draw(buttonID ( which in this case is 1) )

im calling install with:


button.install(1,3,2,4,colors.red,colors.white,"Hello","testFunction",2) -- last variable is buttonID
and then drawing with

button.draw(2)
remiX #4
Posted 16 April 2013 - 06:28 AM
setPos(buttons[buttonID][xMin], buttons[buttonID][yMin])

All the lines with [xMin] [yMin] [tCol] [bCol] are giving the problems.
It's thinking you're trying to access a variable xMin and not the xMin value of the table.

Change it all to .xMin .yMin .tCol .bCol

setPos(buttons[buttonID].xMin, buttons[buttonID].yMin)
etc

EDIT: I remember someone saying this that you can't access number variables in a table like [xMin] etc, you need to use .xMin

If someone could confirm..
Goof #5
Posted 16 April 2013 - 07:14 AM
EDIT:

Thanks.. it worked! now i'll continue my hard work…