Advertisement
GladdeSnaak

Miner

Feb 6th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. cords = {}
  2. cords["X"] = {}
  3. cords["X"] = 0
  4. cords["Y"] = {}
  5. cords["Y"] = 0
  6. sessioncount = 0
  7. function checkFuel()
  8. while range()>turtle.getFuelLevel() do
  9.         for C = 1,16 do
  10.     G = turtle.getItemDetail(C)
  11.     if G["name"] == "minecraft:coal" then
  12.     turtle.refuel(G["count"])
  13.     end
  14.     end
  15.     end
  16.  
  17. end
  18.  
  19. function range()
  20. return cords["X"] + cords["Y"]
  21. end
  22.  
  23. function mine()
  24. turtle.dig()
  25.     turtle.digUp()
  26.     turtle.up()
  27.     checkFuel()
  28.         turtle.dig()
  29.         turtle.digUp()
  30.         turtle.up()
  31.         checkFuel()
  32.             turtle.dig()
  33.             checkFuel()
  34.         turtle.digDown()
  35.         turtle.down()
  36.         checkFuel()
  37.     turtle.digDown()
  38.     turtle.down()
  39.     checkFuel()
  40. turtle.turnLeft()
  41. turtle.dig()
  42.     turtle.digUp()
  43.     turtle.up()
  44.     checkFuel()
  45.         turtle.dig()
  46.         turtle.digUp()
  47.         turtle.up()
  48.         checkFuel()
  49.             turtle.dig()
  50.             checkFuel()
  51.         turtle.digDown()
  52.         turtle.down()
  53.         checkFuel()
  54.     turtle.digDown()
  55.     turtle.down()
  56.     checkFuel()
  57. turtle.turnRight()
  58. turtle.turnRight()
  59. turtle.dig()
  60.     turtle.digUp()
  61.     turtle.up()
  62.     checkFuel()
  63.         turtle.dig()
  64.         turtle.digUp()
  65.         turtle.up()
  66.         checkFuel()
  67.             turtle.dig()
  68.             checkFuel()
  69.         turtle.digDown()
  70.         turtle.down()
  71.         checkFuel()
  72.     turtle.digDown()
  73.     turtle.down()
  74.     checkFuel()
  75. forward()
  76. forward()
  77. forward()
  78. go()
  79. else
  80. forward()
  81. go()
  82. end
  83. end
  84. end
  85.  
  86. function updateCords(x,y)
  87. cords["X"] = x + cords["X"]
  88. cords["Y"] = y + cords["Y"]
  89. end
  90.  
  91. function goHome()
  92. if cords["X"] < 0 then
  93. turtle.turnRight()
  94. elseif cords["X"] == 0 then
  95. else
  96. turtle.turnLeft()
  97. end
  98.  
  99. dist = math.abs(cords["X"])
  100. for X = 1, dist do
  101. turtle.dig()
  102. turtle.forward()
  103. end
  104.  
  105. if cords["Y"] < 0 then
  106. ydist = math.abs(cords["Y"])
  107. turtle.turnLeft()
  108. turtle.turnLeft()
  109. for Y = 1,ydist do
  110. turtle.dig()
  111. turtle.forward()
  112. end
  113. else
  114. ydist = math.abs(cords["Y"])
  115. for Y = 1,ydist do
  116. turtle.dig()
  117. turtle.forward()
  118. end
  119. end
  120. end
  121.  
  122. function go()
  123. mine()
  124. sessioncount = sessioncount + 1
  125. forward()
  126. end
  127.  
  128.  
  129. function forward()
  130. if sessioncount <= 100 then
  131. turtle.forward()
  132. go()
  133. else
  134. goHome()
  135. end
  136. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement