DrFair

MFR Spawner turtle

Mar 19th, 2014
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. rednet.open("right")
  2. msg = "spawner"
  3. side = "front"
  4. reversed = true
  5. active = false
  6.  
  7. function update()
  8. if reversed then
  9. rs.setOutput(side,not active)
  10. else
  11. rs.setOutput(side,active)
  12. end
  13. end
  14.  
  15. function replace(num)
  16. turtle.suck()
  17. turtle.select(num)
  18. turtle.drop()
  19. end
  20.  
  21. update()
  22.  
  23. while true do
  24. event,id,message = os.pullEvent()
  25. if event == "rednet_message" then
  26. print("Got message: "..message)
  27. if message == msg.." on" then
  28. active = true
  29. update()
  30. print("Turned on.")
  31. rednet.broadcast(msg.." on.")
  32. elseif message == msg.." off" then
  33. active = false
  34. update()
  35. print("Turned off.")
  36. rednet.broadcast(msg.." off.")
  37. elseif string.sub(message, 0, 4) == "pick" then
  38. replace(tonumber(string.sub(message, 6, 6)))
  39. end
  40. end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment