condecero

PhyscoKillerMonkey Turtle 02

Dec 11th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. --Open rednet, make clearing the screen a single function
  2. rednet.open("right")
  3. function clear() term.clear() term.setCursorPos(1, 1) end
  4. while true do
  5. clear()
  6. print("Connected, ID: ", os.computerID(), ". Listening for requests.")
  7. rednet.broadcast("Listening") --Tell all other computers in the area that this turtle is ready and waiting for orders
  8. local id, msg = rednet.receive(10) --Wait for a return message for 10 seconds, then repeat
  9. if msg == "goto" then --If the incoming message is a goto request then prepare for coordinates (other commands can be added in this if statement in the future
  10. print("Goto request from ", id, ", getting coordinates...")
  11. local id, msg = rednet.receive()
  12. gox = tonumber(msg) --Because only strings can be send over rednet the coordinates are changed to and from strings on each side of the message
  13. local id, msg = rednet.receive()
  14. goy = tonumber(msg)
  15. local id, msg = rednet.receive()
  16. goz = tonumber(msg)
  17. print("Coordinates recived, going to ", gox, " ", goy, " ", goz)
  18. shell.run("goto", gox, goy, goz) --Run the goto program with the recived coordinates
  19. end
  20. end
Add Comment
Please, Sign In to add comment