Jump to content




[Solved] 2 Simultaneous Os.pullevent(Type)


  • You cannot reply to this topic
2 replies to this topic

#1 CCJJSax

  • Members
  • 262 posts

Posted 31 August 2013 - 01:50 AM

I'm adding on to my program that has may options with an os.pullEvent("char"). now I'm working with miscperipherals' chat turtles, and it adds an event os.pullEvent("chat"). I would like to be able to push w for a turtle.forward(). but at the same time I'd like to be able to say "forward "..number in the chat box and have it follow whichever event type it receives at the time.

Edit: Actually.... Wouldn't this be in a parallel.waitForAny(os.pullEvent(), os.pullEvent()) ???

#2 BigTwisty

  • Members
  • 106 posts

Posted 31 August 2013 - 02:00 AM

I would try this:
while true do
  event, p1, p2 = os.pullEvent()
  if event=="char" then
    if p1=="w" then
	  turtle.forward()
    end
  elseif event=="chat" then
    if p1=="forward" then
	  turtle.forward()
    end
  end
end


#3 CCJJSax

  • Members
  • 262 posts

Posted 31 August 2013 - 02:30 AM

View PostBigTwisty, on 31 August 2013 - 02:00 AM, said:

I would try this:
while true do
  event, p1, p2 = os.pullEvent()
  if event=="char" then
	if p1=="w" then
	  turtle.forward()
	end
  elseif event=="chat" then
	if p1=="forward" then
	  turtle.forward()
	end
  end
end

Yep. That did it :D thanks so much!





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users