Jharii

rednetTestTurtle

Jan 20th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1. turnDirection = "Left"
  2. testTurtle = function()
  3.   rednet.open("right") --enable modem on the right side of the PC
  4.   id,message = rednet.receive() --wait until a mesage is received
  5.   if id == 4 then
  6.     if message == "Turn Left" then
  7.       turnDirection = "Left"
  8.     elseif message == "Turn Right" then
  9.       turnDirection = "Right"  
  10.     end
  11.     rednet.send(4,os.GetLabel() .. " is now turning " .. turndirection)
  12.   end
  13.   rednet.close("right") -- disable modem on the right side of the PC
  14. end
  15.  
  16. turn = function()
  17.   if turnDirection == "Left" then
  18.     turtle.turnLeft()
  19.   else
  20.     turtle.turnRight()
  21.   end
  22. end
  23.  
  24. parallel.waitForAny(testTurtle,turn)
Advertisement
Add Comment
Please, Sign In to add comment