Posted 23 June 2013 - 10:53 AM
So I made a few buttons that work fine, mostly.
When I reboot the computer and try to click one of them for the first time it errors with 'attempt to call nil', and after that it works fine.
When I reboot the computer and try to click one of them for the first time it errors with 'attempt to call nil', and after that it works fine.
local buttons = {
[1] = {sX = 1, eX = 13, sY = 04, eY = 06, txt = "Btn 1", cmd = btn1},
[2] = {sX = 1, eX = 13, sY = 08, eY = 10, txt = "Btn2", cmd = btn2}
}
function handleMenu()
while true do
event = {os.pullEvent()}
if event[1] == "mouse_click" then
for k, v in ipairs(buttons) do
if event[3] >= buttons[k].sX and event[3] <= buttons[k].eX and event[4] >= buttons[k].sY and event[4] <= buttons[k].eY then
buttons[k].cmd()
end
end
end
end
end
function btn1()
-- Write function
writeStr("Btn1", 1, 1, colors.white)
end
function btn2)
-- Write function
writeStr("Btn2", 1, 1, colors.white)
end