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

os.pullEventRaw() help

Started by bobmandude9889, 12 September 2013 - 08:24 PM
bobmandude9889 #1
Posted 12 September 2013 - 10:24 PM
Title: os.pullEventRaw() help
I don't understand how to use os.pullEventRaw(). On the wiki it says it won't stop the program to wait for an event but when I use it it does. Also the wiki doesn't give any example code. How do I use os.pullEventRaw() correctly?
Bubba #2
Posted 12 September 2013 - 11:08 PM
os.pullEventRaw is essentially the same thing as os.pullEvent, but without handling termination. I would not use it unless for security purposes, but if you need to then the usage is exactly the same as os.pullEvent. Just be aware that you will have to use a disk drive and a startup file in order to reset the computer if you make a mistake with os.pullEventRaw.
PixelToast #3
Posted 12 September 2013 - 11:09 PM
os.pullEventRaw is os.pullEvent, the only difference is that os.pullEvent will allow you to terminate by holding ctrl-t
BigTwisty #4
Posted 13 September 2013 - 01:05 AM
os.pullEvent(event) simply calls os.pullEventRaw() over and over again until it gets something it handles behind the scenes, like "terminate", or it gets the desired event. The only reason to use it would be that you want to capture one of those behind-the-scenes events. For a newer programmer I would suggest you stick to os.pullEvent() and let Lua handle the stuff you don't need to.
bobmandude9889 #5
Posted 13 September 2013 - 01:09 PM
Then how does the worm game move the worm while checking if you press a button?
PixelToast #6
Posted 13 September 2013 - 01:12 PM
Then how does the worm game move the worm while checking if you press a button?
it checks for key events, see here: http://computercraft.info/wiki/Os.pullEvent
Lyqyd #7
Posted 13 September 2013 - 01:48 PM
It looks at both key and timer events. You can actually read the code for it. Use the edit program to open /rom/programs/worm.
bobmandude9889 #8
Posted 14 September 2013 - 12:54 AM
I didn't realize there are timer events. Thank you