Advertisement
EphemeralKap

Untitled

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