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

os.pullEvent() - multiple inputs

Started by cukier, 05 February 2016 - 03:42 PM
cukier #1
Posted 05 February 2016 - 04:42 PM
hey all!

i want os.pullEvent() to react ONLY on two types of events but i dont know how to do it.
i tried: os.pullEvent("key", "event") but that dont work

can someone tell is it possible ?
sory for my ENG
Lyqyd #2
Posted 05 February 2016 - 05:35 PM
You call it without a filter and then use if statements to handle the two events you're interested in separately.
wilcomega #3
Posted 05 February 2016 - 07:24 PM

local ev, arg1, arg2, arg3, arg4 = os.pulLEvent()
if ev == "rednet_message" then

elseif ev == "key_down" then

end 

replace the ev == "…" with whatever events you want to listen for

Edit: elseif is more efficient but buth work fine
Edited on 05 February 2016 - 07:36 PM
Lyqyd #4
Posted 05 February 2016 - 07:41 PM
Rather than separate if blocks, one should use elseif to branch out to handle the different events.