Advertisement
Voxxel

Stripmine 1.12

Jul 5th, 2020
1,424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.03 KB | None | 0 0
  1. local distance = 0
  2. local width = 0
  3. local direction = 0
  4. local multi = 0
  5. local multiCounter = 0
  6. local torchCounter = 0
  7. local tracker = 0
  8. local torchSlot = 0
  9. local buildSlot = 0
  10.  
  11. function forward(a)
  12.     local i = 0
  13.     while i < a do
  14.         while turtle.detectUp() do
  15.             turtle.digUp()
  16.         end
  17.         while turtle.detect() do
  18.             turtle.dig()
  19.         end
  20.         if turtle.forward() then
  21.             tracker = tracker + 1
  22.         end
  23.         if turtle.detectDown() == false then
  24.             for i = 1, 16 do
  25.                 local item_data = turtle.getItemDetail(i)
  26.                 if item_data then
  27.                     if item_data.name == "minecraft:cobblestone" then
  28.                         buildSlot = i
  29.                         print("New Build Slot: ", buildSlot)
  30.                         break
  31.                     end
  32.                 end
  33.             end
  34.             turtle.select(buildSlot)
  35.             turtle.placeDown()
  36.             turtle.select(1)
  37.         end
  38.         torchCounter = torchCounter + 1
  39.         torchCheck()
  40.         i = i+1
  41.     end
  42. end
  43.  
  44. function turn()
  45.     if direction == 0 then
  46.         turtle.turnLeft()
  47.     elseif direction == 1 then
  48.         turtle.turnRight()
  49.     end
  50.     forward(width+1)
  51.     if direction == 0 then
  52.         turtle.turnLeft()
  53.         direction = 1
  54.     elseif direction == 1 then
  55.         turtle.turnRight()
  56.         direction = 0
  57.     end
  58. end
  59.  
  60. function torchCheck()
  61.     if torchCounter >= 11 then
  62.         for i = 1, 16 do
  63.             local item_data = turtle.getItemDetail(i)
  64.             if item_data then
  65.                 if item_data.name == "minecraft:torch" then
  66.                     torchSlot = i
  67.                     print("New Torch Slot: ", torchSlot)
  68.                     break
  69.                 end
  70.             end
  71.         end
  72.         turtle.select(torchSlot)
  73.         if turtle.getItemCount() >= 1 then
  74.             turtle.turnLeft()
  75.             turtle.turnLeft()
  76.             turtle.place()
  77.             torchCounter = 0
  78.             turtle.turnLeft()
  79.             turtle.turnLeft()
  80.         end
  81.         turtle.select(1)
  82.     end
  83. end
  84.  
  85. function checkIfFuel()
  86.     return turtle.refuel(0)
  87. end
  88.  
  89. function refuel()
  90.     local fuelLimit = turtle.getFuelLimit()
  91.     if turtle.getFuelLevel() < (fuelLimit / 8) then
  92.         print("Fuel Limit: ", fuelLimit)
  93.         print("Current Fuel: ", turtle.getFuelLevel())
  94.         for i = 1, 16 do
  95.             turtle.select(i)
  96.             if checkIfFuel() then
  97.                 turtle.refuel()
  98.             end
  99.         end
  100.     end
  101. end
  102.  
  103. function transfer()
  104.     if direction == 1 then
  105.         turtle.turnLeft()
  106.     elseif direction == 0 then
  107.         turtle.turnRight()
  108.     end
  109.     while turtle.detectUp() do
  110.         turtle.digUp()
  111.     end
  112.     turtle.up()
  113.    
  114.     for i = 1, multiCounter * (2 * width + 2) do
  115.         while turtle.detect() do
  116.             turtle.dig()
  117.         end
  118.         if turtle.forward() then
  119.             tracker = tracker + 1
  120.         end
  121.     end
  122.     turtle.down()
  123.    
  124.     if direction == 1 then
  125.         turtle.turnLeft()
  126.     elseif direction == 0 then
  127.         turtle.turnRight()
  128.     end
  129. end
  130.  
  131. function checkInventory()
  132.     empty_slots = 0
  133.     for i = 1, 16 do
  134.         if turtle.getItemCount(i) == 0 then
  135.             empty_slots = empty_slots + 1
  136.         end
  137.     end
  138.     if empty_slots <= 3 then
  139.         transfer()
  140.         clearInventory()
  141.         transfer()
  142.     end
  143. end
  144.  
  145. function clearInventory()
  146.     for i = 1, 16 do
  147.         local item_data = turtle.getItemDetail(i)
  148.         if item_data then
  149.             if item_data.name ~= "minecraft:torch" then
  150.                 turtle.select(i)
  151.                 turtle.drop()
  152.             end
  153.         end
  154.     end
  155.    
  156. end
  157.  
  158. function start()
  159.     print("Starting!")
  160.     os.sleep(2)
  161.     print("Fuel Limit: ", turtle.getFuelLimit())
  162.     print("Current Fuel: ", turtle.getFuelLevel())
  163.     turtle.select(1)
  164.     while multiCounter < multi do
  165.         checkInventory()
  166.         forward(distance)
  167.         turn()
  168.         forward(distance)
  169.         turn()
  170.         refuel()
  171.         multiCounter = multiCounter + 1
  172.     end
  173.     transfer()
  174.     clearInventory()
  175.     turtle.turnLeft()
  176.     turtle.turnLeft()
  177.     print("Dunsoo!")
  178.     print("I moved ", tracker, "blocks! :)")
  179. end
  180.  
  181. print("Welcome to Voxxels Stripmining program")
  182. print("-----------------------------------")
  183. print("How far do you want to go?")
  184. input1 = io.read()
  185. distance = tonumber(input1)
  186.  
  187. print("-----------------------------------")
  188. print("How many blocks between the tunnels?")
  189. input2 = io.read()
  190. width = tonumber(input2)
  191.  
  192. print("----------------------------------")
  193. print("Left or Right?")
  194. print("(0 = Left ; 1 = Right)")
  195. input3 = io.read()
  196. direction = tonumber(input3)
  197.  
  198. print("----------------------------------")
  199. print("Ok almost done.")
  200. print("How often should I repeat that?")
  201. input4 = io.read()
  202. multi = tonumber(input4)
  203.  
  204. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement