Posted 10 April 2013 - 12:11 AM
Hi!
I have a problem!
I'm trying to make a program that prints the time and a button to exit it.
I can run the program but the button won't do anything.
Heres my code:
What am I doing wrong?
I have a problem!
I'm trying to make a program that prints the time and a button to exit it.
I can run the program but the button won't do anything.
Heres my code:
Spoiler
function main()
term.clear()
term.setBackgroundColor(1)
term.setTextColor(32768)
term.clear()
term.setCursorPos(1,1)
print("The time is: ")
term.setCursorPos(1,3)
print(textutils.formatTime(os.time(), true))
term.setCursorPos(1,5)
print("[Exit]")
slc = 0
sleep(1)
main()
while true do
event, button, x, y = os.pullEvent("mouse_click")
if event == "mouse_click" then
if slc == 0 then
if x >= 1 and x <= 6 and y == 5 and button == 1 then
term.clear()
term.setCursorPos(1,1)
print("Exited!")
sleep(5)
os.reboot()
else
main()
end
end
end
end
end
main()
What am I doing wrong?