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

How do you wait for an event to happen twice?

Started by XMrPotatoX, 05 November 2013 - 06:03 PM
XMrPotatoX #1
Posted 05 November 2013 - 07:03 PM
Lets say I have this code

event = os.pullEvent()
if event == "mouse_click" then
  print "Yay"
end

How would I make it wait to print the message only after I've clicked twice?
Lyqyd #2
Posted 05 November 2013 - 07:56 PM
Split into new topic.

Well, if all you want is to ensure that you get two mouse click events in a row, you can do dumb tricks like this:


if (os.pullEvent()) == "mouse_click" and (os.pullEvent()) == "mouse_click" then

But if you want anything more complex than two mouse clicks anywhere any time apart with no other events in between, you'd need to do it differently.
XMrPotatoX #3
Posted 05 November 2013 - 08:36 PM
Split into new topic.

Well, if all you want is to ensure that you get two mouse click events in a row, you can do dumb tricks like this:


if (os.pullEvent()) == "mouse_click" and (os.pullEvent()) == "mouse_click" then

But if you want anything more complex than two mouse clicks anywhere any time apart with no other events in between, you'd need to do it differently.

Yeah that worked. Can't believe I didn't think of that :D/> Thanks a million.