Advertisement
EphemeralKap

Untitled

Dec 5th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. -- 0 = Return, 1 = Maintenance, 2 = Farming, 3 = Critical
  2. local status = 0
  3. local n = 3
  4. local length = 9
  5. local stepsToGo = 9
  6. local stepsSoFar = 0
  7.  
  8. --Return to station
  9. function Return()
  10. if status == 0 then
  11. local front = GetBlock(1)
  12. if front == "botania:flower" then
  13. turtle.dig()
  14. turtle.forward()
  15. elseif front == "botania:specialflower" then
  16. turtle.turnLeft()
  17. elseif front == "minecraft:chest" then
  18. turtle.turnLeft()
  19. turtle.dig()
  20. turtle.forward()
  21. turtle.turnRight()
  22. turtle.forward()
  23. turtle.turnLeft()
  24. status = 1
  25. else
  26. local under = GetBlock(3)
  27. if under == "minecraft:stone" or under == "minecraft:grass" then
  28. turtle.forward()
  29. elseif under == "minecraft:cobblestone" then
  30. turtle.back()
  31. turtle.turnLeft()
  32. else
  33. status = 3
  34. end
  35. end
  36. end
  37. end
  38.  
  39. -- Inspects the block infront, above or below the turtle.
  40. function GetBlock(side)
  41. if side == 1 then
  42. local s, d = turtle.inspect()
  43. if s then return d.name else return false end
  44. elseif side == 2 then
  45. local s, d = turtle.inspectUp()
  46. if s then return d.name else return false end
  47. elseif side == 3 then
  48. local s, d = turtle.inspectDown()
  49. if s then return d.name else return false end
  50. end
  51. end
  52.  
  53. function Refuel()
  54. print("Refueling..")
  55. turtle.select(1)
  56. if not turtle.refuel(3) then
  57. print("Fuel reserves low.. Returning home")
  58. status = 0
  59. end
  60. end
  61.  
  62. function PickFlowers()
  63. local front = GetBlock(1)
  64. if front == "botania:flower" then
  65. turtle.dig()
  66. turtle.forward()
  67. elseif front == "botania:specialflower" then
  68. turtle.turnLeft()
  69. status = 0
  70. return
  71. else
  72. turtle.forward()
  73. end
  74.  
  75. stepsSoFar = stepsSoFar + 1
  76. if stepsSoFar == stepsToGo then n = n - 1 end
  77. if n == 0 then stepsToGo = stepsToGo - 1 end
  78.  
  79. end
  80.  
  81. function GrabFuel()
  82. if turtle.getItemCount(1) > 0 then
  83. if turtle.getItemDetail(1).name ~= "minecraft:coal" then
  84. print("That's not fuel.. Ew!")
  85. turtle.select(1)
  86. turtle.drop()
  87. end
  88. end
  89. if turtle.getItemCount(1) < 16 and status == 1 then
  90. print("Grabbing Fuel..")
  91. turtle.select(1)
  92. turtle.suckDown()
  93. end
  94. end
  95.  
  96. function DropOff()
  97. turtle.turnLeft()
  98. turtle.turnLeft()
  99. for i=2,16 do
  100. if turtle.getItemCount(i) > 0 then
  101. turtle.select(i)
  102. turtle.dropUp()
  103. end
  104. end
  105. turtle.turnLeft()
  106. turtle.turnLeft()
  107. end
  108.  
  109. --main loop
  110. while true do
  111. if turtle.getFuelLevel() < 10 then
  112. Refuel()
  113. end
  114. if status = 0 then
  115. print("Finding home..")
  116. Return()
  117. end
  118. if status == 1 then
  119. n = 3
  120. stepsToGo = 9
  121. stepsSoFar = 0
  122.  
  123. print("Refueling.. Storing.. Polishing..")
  124. DropOff()
  125. GrabFuel()
  126. print("Maintenance completed!")
  127. status = 2
  128. end
  129. if status == 2 then
  130. print("Picking Flowers..")
  131. end
  132. if status == 3 then
  133. print("Critical error..")
  134. sleep(20)
  135. break
  136. end
  137. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement