Advertisement
thadudexx

Untitled

Oct 23rd, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. --[[ KillBot ]]
  2. local status = false
  3. local controller = 19
  4. direction = ""
  5. attackMethod = "attack" .. direction
  6. suckMethod = "suck" .. direction
  7.  
  8. rednet.open("left") -- turtle starts by idling until a rednet signal is received
  9. print("waiting")
  10.  
  11. local function listen()
  12. id, message = rednet.receive()
  13. if message == "stopfarm" then -- recognizes only message stopfarm
  14. if status == true then
  15. print("stoped")
  16. rednet.send(controller, "stoped")
  17. status = false
  18. else
  19. rednet.send(controller, "not running")
  20. end
  21. elseif message == "startfarm" then -- recognizes only message startfarm
  22. if status == false then
  23. print("started")
  24. rednet.send(controller, "started")
  25. status = true
  26. else
  27. rednet.send(controller, "running")
  28. rednet.close()
  29. end
  30. elseif message "status" then -- another alternative command that should tell the status of the turtle
  31. if redstone.getOutput("bottom") == false then
  32. rednet.send(controller, "inactive")
  33. else
  34. rednet.send(controller, "active")
  35. end
  36. end
  37. end
  38.  
  39. local function killcollect()
  40. while true do
  41. -- print("attacking")
  42. _G["turtle"][attackMethod]()
  43. -- print("sucking")
  44. _G["turtle"][suckMethod]()
  45. -- print("dropping")
  46. for c = 1, 16 do
  47. turtle.select(c)
  48. turtle.dropDown()
  49. end
  50. end
  51. end
  52.  
  53. while true do
  54. if status == true then
  55. parallel.waitForAny(listen,killcollect)
  56. else
  57. listen();
  58. end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement