Posted 12 August 2014 - 03:58 PM
Hey!
Im new here to the forums and also new to LUA so i don't know if there's an existing post and I couldn't find something on google. So, how you could see in the title, my problem is that i don't know how I should break a loop with a monitor_touch event.
I'll explain briefly what this program does: I programmed it for a mobfarm I built. There are 5 buttons, each of them showing a number. If you press one of these buttons, a timer will start, the computer connected to the monitor will ouput a redstone signal and the farm starts to work until the timer is over. Then you're back in the menu where the 5 buttons are.
My problem: While the timer is running, I'd like to add a button to cancel the timer and immediately return to the menu. But I can't get the code right. Either the timer doesn't "time" or the button doesn't react to the monitor_touch.
The code for the timer is the following:
You can find the full code on pastebin: http://pastebin.com/AfTkq4mD
Thanks for any replies!
Im new here to the forums and also new to LUA so i don't know if there's an existing post and I couldn't find something on google. So, how you could see in the title, my problem is that i don't know how I should break a loop with a monitor_touch event.
I'll explain briefly what this program does: I programmed it for a mobfarm I built. There are 5 buttons, each of them showing a number. If you press one of these buttons, a timer will start, the computer connected to the monitor will ouput a redstone signal and the farm starts to work until the timer is over. Then you're back in the menu where the 5 buttons are.
My problem: While the timer is running, I'd like to add a button to cancel the timer and immediately return to the menu. But I can't get the code right. Either the timer doesn't "time" or the button doesn't react to the monitor_touch.
The code for the timer is the following:
Spoiler
function Timer()
while time >= 0.2 do
CancelButton()
m.clear()
m.setCursorPos(1,3)
m.write(time)
time = time - 0.1
sleep(0.1)
event,side,x,y = os.pullEvent()
if event == "monitor_touch" then
if x >= 1 and y == 5 then
time = 0
break
end
end
end
end
You can find the full code on pastebin: http://pastebin.com/AfTkq4mD
Thanks for any replies!