Pull event without yelding?
#1
Posted 26 October 2012 - 01:17 PM
#2
Posted 26 October 2012 - 01:23 PM
#3
Posted 26 October 2012 - 01:23 PM
os.pullEventRaw consists of a single line of code, unfortunately for you that line is return coroutine.yield
#4
Posted 26 October 2012 - 01:26 PM
local evtTimeout = os.startTimer(0.05) //Single-Tick Timer
local evt = {os.pullEvent()}
if evt[2] == evtTimeout then
//Event Timeout
end
#5
Posted 26 October 2012 - 01:43 PM
#7
Posted 26 October 2012 - 01:57 PM
#9
Posted 26 October 2012 - 02:15 PM
#10
Posted 26 October 2012 - 02:18 PM
#11
Posted 26 October 2012 - 02:29 PM
local tQueue={}
local queuer=coroutine.wrap(function() while true do tQueue[#tQueue+1]={os.pullEvent()} end end)
local function pull()
return table.remove(tQueue,1)
end
unfortunately you will need to make your code a coroutine too though
#12
Posted 26 October 2012 - 02:31 PM
Orwell, on 26 October 2012 - 02:11 PM, said:
Cloudy, on 26 October 2012 - 02:15 PM, said:
Orwell, on 26 October 2012 - 02:18 PM, said:
#13
Posted 26 October 2012 - 02:35 PM
Orwell, on 26 October 2012 - 02:11 PM, said:
It starts a timer and then pulls events until it gets that timer.
Basically it's intercepting events from being passed to the calling program until the timer ends.
#14
Posted 26 October 2012 - 02:45 PM
#15
Posted 26 October 2012 - 03:13 PM
#16
Posted 26 October 2012 - 03:30 PM
Lyqyd, on 26 October 2012 - 02:45 PM, said:
if you have a simultaneous coroutine listening it will still be recorded though
#17
Posted 26 October 2012 - 04:49 PM
KaoS, on 26 October 2012 - 03:30 PM, said:
Lyqyd, on 26 October 2012 - 02:45 PM, said:
if you have a simultaneous coroutine listening it will still be recorded though
Lyqyd, on 26 October 2012 - 02:45 PM, said:
As you can see, I am well aware of that fact. An easy way to demonstrate this is to use bundled cable rednet to send a large message to a computer, then have the receiving computer sleep for a short time when the message starts being received. The rednet.run() function, running in parallel with the shell, will still see all of the events come in, despite the other program sleeping.
#18
Posted 26 October 2012 - 05:12 PM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











