Advertisement
temposabel

excavate

Dec 20th, 2021 (edited)
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.38 KB | None | 0 0
  1. function depo()
  2.     throw_shit()
  3.     refuel()
  4. end
  5.  
  6. function findslot(name,skipg)
  7.     skipg = skipg or false
  8.     if name == "minecraft:grass_block" then
  9.         name = "minecraft:dirt"
  10.     end
  11.  
  12.     if name == "minecraft:coal_ore" then
  13.         name = "minecraft:coal"
  14.     end
  15.  
  16.     if name == "minecraft:redstone_ore" then
  17.         name = "minecraft:redstone"
  18.     end
  19.  
  20.     if name == "minecraft:lapis_ore" then
  21.         name = "minecraft:lapis_lazuli"
  22.     end
  23.  
  24.     if name == "minecraft:emerald_ore" then
  25.         name = "minecraft:emerald"
  26.     end
  27.  
  28.     if name == "minecraft:diamond_ore" then
  29.         name = "minecraft:diamond"
  30.     end
  31.  
  32.     if name == "minecraft:stone" then
  33.         name = "minecraft:cobblestone"
  34.     end
  35.     if name == "minecraft:cobweb" then
  36.         name = "minecraft:string"
  37.     end
  38.     if name == "minecraft:gravel" then
  39.         return 1
  40.     end
  41.  
  42.     if name then
  43.         firstempty = false
  44.         for i = 1,16 do
  45.             slotitem = turtle.getItemDetail(i)
  46.             if slotitem then
  47.                 if name == slotitem.name then
  48.                     if slotitem.count < 64 then
  49.                         return i
  50.                     end
  51.                 end
  52.             else
  53.                 if not firstempty then firstempty = i end
  54.             end
  55.         end
  56.         if firstempty then return firstempty end
  57.         return false
  58.     end
  59.     return 1
  60. end    
  61.  
  62.  
  63. function tablelength(T)
  64.     local count = 0
  65.     for _ in pairs(T) do count = count + 1 end
  66.     return count
  67.   end
  68.  
  69.  -- vvv fuel limit removed, replace true with
  70. function refuel()
  71.     print(turtle.getFuelLevel())
  72.     if  turtle.getFuelLevel() < 60 then
  73.         found = find("minecraft:coal")
  74.         if found then
  75.             turtle.select(found)
  76.             turtle.refuel(1)
  77.         end
  78.     end
  79. end
  80.  
  81.  
  82. intebajs = {'minecraft:diamond', 'minecraft:iron_ore', 'minecraft:gold_ore', 'minecraft:emerald', 'minecraft:obsidian', 'minecraft:coal'}
  83.  
  84. function in_list (tab, val)
  85.     for index, value in ipairs(tab) do
  86.         if value == val then
  87.             return true
  88.         end
  89.     end
  90.  
  91.     return false
  92. end
  93.  
  94. function throw_shit()
  95.     for i = 1,16 do
  96.         sname = turtle.getItemDetail(i)
  97.         if sname then
  98.             if not in_list(intebajs,sname.name) then turtle.select(i) turtle.dropDown() end
  99.         end
  100.     end
  101. end
  102.  
  103. function find(name)
  104.     for i = 1,16 do
  105.         sname = turtle.getItemDetail(i)
  106.         if sname then
  107.             sname = sname.name
  108.             if name == sname then
  109.                 return i
  110.             end
  111.         end
  112.     end
  113.     return false
  114. end
  115.  
  116. function findnextslot()
  117.     for i = 1,16 do
  118.         if turtle.getItemCount(i) ~= 0 then return i
  119.         end
  120.     end
  121. end
  122.  
  123.  
  124. function mine()
  125.     refuel()
  126.     itemsuc,item = turtle.inspectUp()
  127.     if item["name"] == "minecraft:bedrock" then turtle.back() turtle.up() turtle.up() turtle.up() turtle.up() turtle.up() turtle.up() turtle.up() turtle.up() os.reboot() end
  128.        
  129.     if itemsuc then
  130.             --print(item["name"])
  131.             slot = findslot(item["name"])
  132.         if slot then
  133.             turtle.select(slot)
  134.             turtle.digUp()
  135.         else
  136.             depo()
  137.             turtle.select(1)
  138.             turtle.digUp()
  139.    
  140.         end
  141.     end
  142.     itemsuc,item = turtle.inspectDown()
  143.     if item["name"] == "minecraft:bedrock" then turtle.up() turtle.up() turtle.up() turtle.up() turtle.up() turtle.up() turtle.up() turtle.up() os.reboot() end
  144.     if itemsuc then
  145.         slot = findslot(item["name"])
  146.         if slot then
  147.             turtle.select(slot)
  148.             turtle.digDown()
  149.         else
  150.             depo()
  151.             turtle.select(1)
  152.             turtle.digDown()    
  153.         end
  154.     end
  155.     itemsuc,item = turtle.inspect()
  156.     if item["name"] == "minecraft:bedrock" then turtle.up() turtle.up() turtle.up() turtle.up() turtle.up() turtle.up() turtle.up() turtle.up() os.reboot() end
  157.     --print(item)
  158.     if itemsuc then
  159.         slot = findslot(item["name"])
  160.         if slot then
  161.             turtle.select(slot)
  162.             turtle.dig()
  163.         else
  164.             depo()
  165.             turtle.select(1)
  166.             turtle.dig()    
  167.         end
  168.     end
  169.  
  170.     suc = turtle.forward()
  171.     return suc
  172. end
  173.  
  174. function digd(x)
  175.     if x < 3 then
  176.         for i = 0,x do
  177.             turtle.digDown()
  178.             turtle.down()
  179.         end
  180.         return 0
  181.     else
  182.         for i = 0,3 do
  183.             turtle.digDown()
  184.             turtle.down()
  185.         end
  186.         return x - 3
  187.     end
  188. end
  189. xl = 2
  190. yl = 12
  191. de = 3
  192.  
  193. function walk (len)
  194.     x = 0
  195.     while x < len do
  196.         if mine() then x = x + 1 end
  197.     end
  198. end
  199.  
  200. while de ~= 0 do
  201.     for xw = 1,xl do
  202.         refuel()
  203.         for yw = 1,yl-1 do
  204.             walk(1)
  205.         end
  206.         turtle.turnRight()
  207.         walk(1)
  208.         turtle.turnRight()
  209.         for yw = 1,yl-1 do
  210.             walk(1)
  211.         end
  212.         if xw ~= xl then
  213.             turtle.turnLeft()
  214.             walk(1)
  215.             turtle.turnLeft()
  216.         else
  217.             if zw ~= de then
  218.                 turtle.digUp()
  219.                
  220.                 turtle.turnRight()
  221.                 for bajs = 0,(xl*2)-1 do
  222.                     turtle.forward()
  223.                 end
  224.                 turtle.turnRight()
  225.                 de = digd()
  226.  
  227.             end
  228.         end
  229.     end
  230. end
  231.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement