Advertisement
Lyqyd

Wither Control

May 25th, 2014
269
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local witherComputers = {111, 104, 112, 113}
  2. local dispatchFuel
  3.  
  4. rednet.open("right")
  5. local base = peripheral.wrap("top")
  6.  
  7. local fuelRoute = {
  8. "north",
  9. "suck",
  10. "drop 48",
  11. "up 3",
  12. "north",
  13. "drop 4",
  14. "east 2",
  15. "south 2",
  16. "drop 4",
  17. "south 2",
  18. "west 2",
  19. "drop 4",
  20. "west 2",
  21. "north 2",
  22. "drop 4",
  23. "east 2",
  24. "down 3",
  25. "stop",
  26. }
  27.  
  28. local function sendAll(message)
  29. for _, id in ipairs(witherComputers) do
  30. rednet.send(id, message)
  31. end
  32. end
  33.  
  34. local function waitForResponses(good)
  35. local received = 0
  36. local waiting = {}
  37. for i = 1, #witherComputers do
  38. waiting[witherComputers[i]] = true
  39. end
  40. while true do
  41. local id, message = rednet.receive()
  42. if waiting[id] and message == good then
  43. received = received + 1
  44. waiting[id] = nil
  45. elseif waiting[id] and message == "fuel" then
  46. dispatchFuel = true
  47. elseif waiting[id] then
  48. return false
  49. end
  50. if received == #witherComputers then
  51. return true
  52. end
  53. end
  54. end
  55.  
  56. while true do
  57. sendAll("construct")
  58. if waitForResponses("ok") then
  59. turtle.select(1)
  60. turtle.suck()
  61. turtle.drop(turtle.getItemCount(1) - 1)
  62. turtle.dropDown()
  63. end
  64. sleep(120)
  65. if dispatchFuel then
  66. base.flyQuad(fuelRoute)
  67. dispatchFuel = false
  68. sleep(10)
  69. end
  70. end
Advertisement
RAW Paste Data Copied
Advertisement