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

Pulling two events

Started by ClassicRockFan, 23 February 2014 - 03:44 PM
ClassicRockFan #1
Posted 23 February 2014 - 04:44 PM
Hey guys, I'm trying to design a GUI and I'm wondering how it would be possible to pull both a key press and a mouse click at the same time. If anyone wants the GUI or wants to look at the code, I'll post it here. Thanks in advance for all of the help.
Lyqyd #2
Posted 23 February 2014 - 04:53 PM
Nope. You can only pull one event each time you call os.pullEvent. Unless you mean simply calling os.pullEvent with no filter? That will allow you to pull each event in the computer's queue. If that's what you mean, you simply remove the filter argument and call:


os.pullEvent()
CometWolf #3
Posted 23 February 2014 - 04:54 PM
os.pullEvent pulls all events, unless you tell it to only get one specific one.

local tEvent = {os.pullEvent()}
if tEvent[1] == "key" then
  --key event
elseif tEvent[1] == "mouse_click"
  --mouse event
end
ClassicRockFan #4
Posted 23 February 2014 - 05:06 PM
I mean do it without a filter yes, but how would I make it call the cords and the button and a key at the same time, a tArgs?
Lyqyd #5
Posted 23 February 2014 - 05:14 PM
Just throw the return values into a table, like CometWolf's example above, then index what you need out of it.
ClassicRockFan #6
Posted 23 February 2014 - 05:22 PM
okay, thanks all for your help