Posted 24 February 2013 - 11:00 AM
                I am trying to make a program that allows you to press certain keys while in a computer, and a turtle respond accordingly. I know how to detect the keys and control the turtle with it but I need to know how to loop the detection so that you don't have to start the program every time you want to tell the turtle to do a different action. This is what I have so far:
Computer:
Help is appreciated!
Thanks! :D/>
                
            Computer:
rednet.open("right")
event, code = os.pullEvent("key")
while true do
  if code == 75 then
	rednet.send(30,"Turn Left")
  elseif code == 77 then
	rednet.send(30,"Turn Right")
  elseif code == 76 then
	rednet.send(30,"Go Back")
  elseif code == 72 then
	rednet.send(30,"Go Forward")
  elseif code == 200 then
	rednet.send(30,"Go Up")
  elseif code == 208 then
	rednet.send(30,"Go Down")
  end
end
Turtle:
rednet.open("right")
while true do
  id, msg = rednet.receive()
  if msg == "Go Forward" then
	turtle.forward()
  elseif msg == "Go Back" then
	turtle.back()
  elseif msg == "Turn Left" then
	turtle.turnLeft()
  elseif msg == "Turn Right" then
	turtle.turnRight()
  elseif msg == "Go Down" then
	turtle.down()
  elseif msg == "Go Up" then
	turtle.up()
  elseif msg == "Attack" then
	turtle.attack()
  end
end
I just need to know how to make the computer program not wait for just one key and then stop.Help is appreciated!
Thanks! :D/>