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

{Question/Lua}PullEvent

Started by Mikeyjd25, 04 September 2012 - 05:49 AM
Mikeyjd25 #1
Posted 04 September 2012 - 07:49 AM
Hi guys, I was just wondering if there is anyway to check for an event: event = os.pullEvent()
without it waiting, or should I just make a timer that will last 10 milliseconds that will pull it out of its waiting if nothing is there?
and will pulling event pull the last event or only work if the event happens while its waiting?


thanks
-mikeyjd25
SadProgrammer #2
Posted 04 September 2012 - 08:03 AM
Nah, os.pullEvent() yields the program until an event happens. So the timer thing could work if you do it correctly. But pullEvent only accepts events while it is running. Get creative!
Cloudy #3
Posted 04 September 2012 - 09:43 AM
pullEvent will pull any event from the queue - even ones that were queued before you ran the command. However read() and sleep() discard any events that they aren't looking for.