Advertisement
karelvysinka

Untitled

Mar 14th, 2023
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 KB | Gaming | 0 0
  1. local chestFrequency = 10
  2. local drahokamy = {
  3.     "minecraft:diamond",
  4.     "minecraft:emerald",
  5.     "minecraft:redstone",
  6.     "minecraft:lapis_lazuli",
  7.     "minecraft:gold_ore",
  8.     "minecraft:iron_ore"
  9. }
  10.  
  11. local function tableContains(table, element)
  12.     for _, value in pairs(table) do
  13.         if value == element then
  14.             return true
  15.         end
  16.     end
  17.     return false
  18. end
  19.  
  20. local function dig()
  21.     turtle.dig()
  22.     turtle.digUp()
  23.     turtle.digDown()
  24. end
  25.  
  26. local function forward()
  27.     while not turtle.forward() do
  28.         turtle.dig()
  29.         turtle.attack()
  30.     end
  31. end
  32.  
  33. local function emptyInventory()
  34.     for i = 1, 16 do
  35.         turtle.select(i)
  36.         local item = turtle.getItemDetail()
  37.         if item and not tableContains(drahokamy, item.name) then
  38.             turtle.drop()
  39.         end
  40.     end
  41. end
  42.  
  43. local function findChestAndEmptyInventory()
  44.     local chestFound = false
  45.     for i = 1, 4 do
  46.         turtle.turnLeft()
  47.         local success, data = turtle.inspect()
  48.         if success and data.name == "minecraft:chest" then
  49.             chestFound = true
  50.             break
  51.         end
  52.     end
  53.     if chestFound then
  54.         emptyInventory()
  55.     end
  56. end
  57.  
  58. local function refuel()
  59.     for i = 1, 16 do
  60.         local fuelLevel = turtle.getFuelLevel()
  61.         if fuelLevel < 500 then
  62.             turtle.select(i)
  63.             turtle.refuel(1)
  64.         end
  65.     end
  66.     turtle.select(1)
  67. end
  68.  
  69. local function mine(steps)
  70.     for step = 1, steps do
  71.         dig()
  72.         forward()
  73.  
  74.         if step % chestFrequency == 0 then
  75.             findChestAndEmptyInventory()
  76.             refuel()
  77.             print("Natěženo:")
  78.             for i = 1, 16 do
  79.                 turtle.select(i)
  80.                 local item = turtle.getItemDetail()
  81.                 if item then
  82.                     print(item.name .. ": " .. item.count)
  83.                 end
  84.             end
  85.             turtle.select(1)
  86.         end
  87.     end
  88. end
  89.  
  90. mine(100) -- Vložte počet kroků pro těžbu
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement