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

What am I doing wrong? (timers with os.pullEvent())

Started by DeGariless, 29 April 2014 - 06:45 PM
DeGariless #1
Posted 29 April 2014 - 08:45 PM
http://pastebin.com/y5kyixuk

I have this program hooked up to 2 monitors via network cable. I think the problem is in my main loop that starts on line 102. the problem is that lines 111 through 118 are never being executed. why not?

I apologize if my code is messy. I am a new programmer and I would appreciate any constructive critisism.
Lyqyd #2
Posted 29 April 2014 - 10:06 PM
Every time your loop gets an event, it will start two new timers. 0.9 is always shorter than 5.1, so that timer will expire first. After that event is handled, the loop restarts and two new timers are started.

Instead, you should start both timers before the while loop begins, then start a new timer at the end of each timer's handler.
DeGariless #3
Posted 29 April 2014 - 10:36 PM
Ahh thanks! I was hoping it would be something simple like that! :)/>