19 posts
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?
1190 posts
Location
RHIT
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.
2217 posts
Location
3232235883
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
107 posts
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.
19 posts
Posted 13 September 2013 - 01:09 PM
Then how does the worm game move the worm while checking if you press a button?
2217 posts
Location
3232235883
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
8543 posts
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.
19 posts
Posted 14 September 2013 - 12:54 AM
I didn't realize there are timer events. Thank you