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

[Solved] 2 Simultaneous Os.pullevent(Type)

Started by CCJJSax, 31 August 2013 - 12:50 AM
CCJJSax #1
Posted 31 August 2013 - 02: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()) ???
BigTwisty #2
Posted 31 August 2013 - 03: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
CCJJSax #3
Posted 31 August 2013 - 03:30 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

Yep. That did it :D/> thanks so much!