Schneemann

TurtleStripMiner

May 9th, 2021 (edited)
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.70 KB | None | 0 0
  1. local blocksToMine = {"minecraft:gold_ore", "minecraft:iron_ore", "minecraft:diamond_ore", "minecraft:lapis_ore", "minecraft:emerald_ore", "minecraft:coal_ore", "minecraft:gold_ore"}
  2.  
  3. local currentMine = 1
  4. local stripMines
  5.  
  6. local function tableContains (tab, val)
  7.     for index, value in ipairs(tab) do
  8.         if value == val then
  9.             return true
  10.         end
  11.     end
  12.  
  13.     return false
  14. end
  15.  
  16. function unload()
  17.     local suc, data = turtle.inspect()
  18.     local itemDet
  19.     if data["name"] == "minecraft:chest" then
  20.         for i=1, 16, 1 do
  21.             turtle.select(i)
  22.             itemDet = turtle.getItemDetail()
  23.             if itemDet["ID"] == "minecraft:coal" && turtle.getFuelLevel() < turtle.getFuelLimit() then
  24.                 turtle.refuel()
  25.             end
  26.             if turtle.drop() == false then
  27.                 print("ERROR: Could not unload - Chest is full!")
  28.             end
  29.         end
  30.     else
  31.         print("ERROR: Could not unload - Chest not found!")
  32.         return
  33.     end
  34. end
  35.  
  36. function forward(table)
  37.     table[table.length + 1] = "fwd"
  38.     turtle.forward()
  39. end
  40.  
  41. function left()
  42.     turtle.turnLeft()
  43.     turtle.dig()
  44.     turtle.forward()
  45.     turtle.turnRight()
  46. end
  47.  
  48. function stripMine()
  49.     local noOre = true
  50.     stripMines[currentMine] = 0
  51.     while noOre do
  52.         stripMines[currentMine] = stripMines[currentMine] + 1
  53.         turtle.dig()
  54.         turtle.forward()
  55.         turtle.digUp()
  56.         local check = checkArea()
  57.         if tableContains(check, true) then
  58.             mineVien
  59.         end
  60.     end
  61. end
  62.  
  63. function mineVien(block)
  64.     local area = checkAreaB(block)
  65.     local path = {}
  66.    
  67.     for i=1, 5, 1 do
  68.         if area[i] == fwd then
  69.             turtle.dig()
  70.             turtle.forward()
  71.             path[] = "fwd"
  72.         elseif area[i] == dwn then
  73.             turtle.digDown()
  74.             turtle.down()
  75.         elseif area[i] == lft then
  76.             turtle.turnLeft()
  77.             turtle.dig()
  78.             turtle.forward()
  79.             turtle.turnRight()
  80.            
  81.         elseif area[i] == rgt then
  82.  
  83.         elseif area[i] == up then
  84.  
  85.         end
  86.     end
  87.    
  88. end
  89.  
  90. function checkArea()
  91.     local fsuccess, fdata = turtle.inspect()
  92.     print("Inspected Forward")
  93.     local usuccess, udata = turtle.inspectUp()
  94.     print("Inspected Up")
  95.     local dsuccess, ddata = turtle.inspectDown()
  96.     print("Inspected Down")
  97.  
  98.     turtle.turnLeft()
  99.     local lsuccess, ldata = turtle.inspect()
  100.     print("Inspected Left")
  101.     turtle.turnRight()
  102.     turtle.turnRight()
  103.     local rsuccess, rdata = turtle.inspect()
  104.     print("Inspected Right")
  105.     turtle.turnLeft()
  106.  
  107.     local up[1],dwn[1],lft[1],rgt[1],fwd[1] = false
  108.  
  109.     if tableContains(blocksToMine, fdata["name"]) == true then
  110.         fwr[1] = true
  111.         fwr[2] = fdata["name"]
  112.     end
  113.     if tableContains(blocksToMine, udata["name"]) == true then
  114.         up[1] = true
  115.         up[2] = udata["name"]
  116.     end
  117.     if tableContains(blocksToMine, ddata["name"]) == true then
  118.         dwn[1] = true
  119.         dwn[2] = ddata["name"]
  120.     end
  121.     if tableContains(blocksToMine, ldata["name"]) == true then
  122.         lft[1] = true
  123.         lft[2] = ldata["name"]
  124.     end
  125.     if tableContains(blocksToMine, rdata["name"]) == true then
  126.         rgt[1] = true
  127.         rgt[2] = rdata["name"]
  128.     end
  129.  
  130.     return up,dwn,lft,rgt,fwd
  131. end
  132.  
  133. function checkAreaB(block)
  134.     local fsuccess, fdata = turtle.inspect()
  135.     print("Inspected Forward")
  136.     local usuccess, udata = turtle.inspectUp()
  137.     print("Inspected Up")
  138.     local dsuccess, ddata = turtle.inspectDown()
  139.     print("Inspected Down")
  140.  
  141.     turtle.turnLeft()
  142.     local lsuccess, ldata = turtle.inspect()
  143.     print("Inspected Left")
  144.     turtle.turnRight()
  145.     turtle.turnRight()
  146.     local rsuccess, rdata = turtle.inspect()
  147.     print("Inspected Right")
  148.     turtle.turnLeft()
  149.  
  150.     local up,dwn,lft,rgt,fwd = false
  151.  
  152.     if fdata["name"] == block then
  153.         fwr = true
  154.     end
  155.     if udata["name"] == block then
  156.         up = true
  157.     end
  158.     if ddata["name"] == block then
  159.         dwn = true
  160.     end
  161.     if ldata["name"] == block then
  162.         lft = true
  163.     end
  164.     if rdata["name"] == block then
  165.         rgt = true
  166.     end
  167.  
  168.     return up,dwn,lft,rgt,fwd
  169. end
  170.  
  171. print(checkArea())
Add Comment
Please, Sign In to add comment