Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local drahokamy = {
- "minecraft:diamond",
- "minecraft:emerald",
- "minecraft:redstone",
- "minecraft:lapis_lazuli",
- "minecraft:gold_ore",
- "minecraft:iron_ore"
- }
- local function tableContains(table, element)
- for _, value in pairs(table) do
- if value == element then
- return true
- end
- end
- return false
- end
- local function dig()
- turtle.dig()
- turtle.digUp()
- turtle.digDown()
- end
- local function moveDown()
- while not turtle.down() do
- turtle.digDown()
- end
- end
- local function moveUp()
- while not turtle.up() do
- turtle.digUp()
- end
- end
- local function emptyInventory()
- for i = 1, 16 do
- turtle.select(i)
- local item = turtle.getItemDetail()
- if item and not tableContains(drahokamy, item.name) then
- turtle.drop()
- end
- end
- end
- local function refuel()
- for i = 1, 16 do
- local fuelLevel = turtle.getFuelLevel()
- if fuelLevel < 500 then
- turtle.select(i)
- turtle.refuel(1)
- end
- end
- turtle.select(1)
- end
- local function findChestAndEmptyInventory()
- local chestFound = false
- for y = 1, 10 do
- if chestFound then
- break
- end
- for x = 1, 10 do
- local success, data = turtle.inspect()
- if success and data.name == "minecraft:chest" then -- Opraveno: Opraven neukončený řetězec
- chestFound = true
- break
- end
- if x < 10 then
- turtle.forward()
- end
- end
- if not chestFound and y % 2 == 0 then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- elseif not chestFound and y % 2 == 1 then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- if chestFound then
- emptyInventory()
- return true
- else
- turtle.turnRight()
- turtle.turnRight()
- for _ = 1, 10 do
- turtle.forward()
- end
- turtle.turnLeft()
- for _ = 1, 10 do
- turtle.forward()
- end
- turtle.turnLeft()
- return false
- end
- end
- local function mineTunnel()
- for y = 1, 30 do
- dig()
- moveDown()
- refuel()
- if y % 10 == 0 then
- local chestFound = findChestAndEmptyInventory()
- if not chestFound then
- print("Nelze najít truhlu, ukončuji činnost.")
- return
- end
- end
- end
- for _ = 1, 30 do
- moveUp()
- end
- end
- local function mineLayer()
- for _ = 1, 10 do
- mineTunnel()
- if turtle.getFuelLevel() < 30 then
- refuel()
- end
- if _ < 10 then
- turtle.turnRight()
- for _ = 1, 9 do
- turtle.forward()
- end
- turtle.turnRight()
- end
- end
- end
- print("Zahajuji tezbu tunelu 10x10x30...")
- mineLayer()
- print("Tezba tunelu dokoncena.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement