Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dangerBlocks = {"minecraft:lava", "minecraft:flowing_lava", "minecraft:water", "minecraft:flowing_water"}
- local function isDangerous()
- local success, data = turtle.inspect()
- if success then
- for _, block in ipairs(dangerBlocks) do
- if data.name == block then
- return true
- end
- end
- end
- return false
- end
- local function dig()
- while turtle.detect() do
- if isDangerous() then
- print("Обнаружен опасный блок! Остановка копания.")
- return false
- end
- turtle.dig()
- end
- return true
- end
- local function digUp()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- local function digDown()
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- local function isInventoryFull()
- for i = 1, 16 do
- if turtle.getItemCount(i) == 0 then
- return false
- end
- end
- return true
- end
- local function returnToChest(steps)
- for i = 1, steps do
- turtle.back()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(1)
- for i = 1, steps do
- turtle.forward()
- end
- end
- local function tunnel(length)
- for i = 1, length do
- if not dig() then return end
- turtle.forward()
- digUp()
- digDown()
- if isInventoryFull() then
- print("Инвентарь полон, возвращение к сундуку.")
- returnToChest(i)
- end
- end
- end
- print("Введите длину туннеля:")
- local length = tonumber(read())
- if length then
- tunnel(length)
- else
- print("Ошибка ввода длины.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement