Advertisement
EphemeralKap

Untitled

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