35 posts
Location
United States of America
Posted 27 April 2016 - 09:23 PM
Hello, I am trying to make a script that can do rednet.recieve() while typing a message. Anybody know how to do this?
2427 posts
Location
UK
Posted 27 April 2016 - 09:35 PM
quicker to code but slower to run way:
http://www.computerc...allel_%28API%29quicker to run but harder to code way: pull events with no filter and then identify the event, if char then replicate the read function, if rednet then do thing with message, else ignore
Edited on 27 April 2016 - 07:36 PM
12 posts
Posted 28 April 2016 - 01:29 AM
quicker to code but slower to run way:
http://www.computerc...allel_%28API%29quicker to run but harder to code way: pull events with no filter and then identify the event, if char then replicate the read function, if rednet then do thing with message, else ignore
A little off topic but it can be quite useful to rewrite the pullEvent function to take multiple arguments.
os.pullEvent("key", "rednet_message")
1080 posts
Location
In the Matrix
Posted 28 April 2016 - 01:31 AM
But why? You have to differentiate between one event or the other anyways, why not just have a no arg os.pullEvent call?
12 posts
Posted 28 April 2016 - 02:13 AM
But why? You have to differentiate between one event or the other anyways, why not just have a no arg os.pullEvent call?
You no longer have to loop os.pullEvent() until you get the event you want. Instead os.pullEvent("key", "char") will wait for one of those events.
7083 posts
Location
Tasmania (AU)
Posted 28 April 2016 - 02:33 AM
The catch there is that "typing a message" relies on more than one keypress. You're going to have to loop it either way.