temposabel

quary

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