Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local spaceBetweenRows = 2
- local spaceBetweenTorches = 10
- local currentRow, currentLength, currentHeight, rows, length, height = 1, 1, 1, 1, 1
- local sunduk
- local turtle = require("robot");
- local fuels = {
- lava = "minecraft:lava_bucket",
- coal = "minecraft:coal",
- }
- local function text(x, y, text)
- print(text)
- end
- local function refuel()
- local fuelLevel = turtle.getFuelLevel()
- local bucketSlot
- if fuelLevel ~= "unlimited" or fuelLevel < 10 then
- for i = 1, 16 do
- local itemDetail = turtle.getItemDetail(i) or {name = "huy"}
- if itemDetail.name == "minecraft:lava_bucket" then
- local oldSlot = turtle.getSelectedSlot()
- turtle.select(i)
- turtle.refuel()
- turtle.select(oldSlot)
- return true
- else
- for key, value in pairs(fuels) do
- if itemDetail.name == value then
- local oldSlot = turtle.getSelectedSlot()
- turtle.select(i)
- turtle.refuel()
- turtle.select(oldSlot)
- return true
- end
- end
- end
- end
- return false
- end
- end
- local function turnBack()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- local function placeSunduk()
- for i = 1, 16 do
- local itemDetail = turtle.getItemDetail(i) or {name = "huy"}
- if itemDetail.name == "minecraft:chest" then
- turnBack()
- sunduk = i
- local oldSlot = turtle.getSelectedSlot()
- turtle.select(i)
- turtle.dig()
- turtle.place()
- turtle.select(oldSlot)
- turnBack()
- return 0
- end
- end
- end
- local function placeTorch()
- for i = 1, 16 do
- local itemDetail = turtle.getItemDetail(i) or {name = "huy"}
- if itemDetail.name == "minecraft:torch" then
- local oldSlot = turtle.getSelectedSlot()
- turtle.select(i)
- turtle.placeDown()
- turtle.select(oldSlot)
- return 0
- end
- end
- end
- local function kopat(direction)
- refuel()
- if turtle.getFuelLevel() == 0 then error("Out of fuel!") end
- if direction == "forward" then
- turtle.dig()
- turtle.attack()
- if not turtle.forward() then kopat(direction) end
- elseif direction == "up" then
- turtle.digUp()
- turtle.attackUp()
- if not turtle.up() then kopat(direction) end
- elseif direction == "down" then
- turtle.digDown()
- turtle.attackDown()
- if not turtle.down() then kopat(direction) end
- else
- turtle.dig()
- end
- end
- ------------------------------------------------------------------------------------------------------------------------
- text(2, 2, "Skolko ryadov: ")
- rows = tonumber(io.read())
- text(2, 4, "Dlina ryada: ")
- length = tonumber(io.read())
- text(2, 6, "Visota ryada: ")
- height = tonumber(io.read())
- placeSunduk()
- kopat("up")
- for r = 1, rows do
- currentRow = r
- --Копать в высоту
- for h = 1, height do
- currentHeight = h
- --Копать вперед
- for l = 1, length do
- currentLength = l
- kopat("forward")
- turtle.digUp()
- turtle.digDown()
- if h == 1 and l % (spaceBetweenTorches + 1) == 0 then
- placeTorch()
- end
- end
- --Возврат назад по длине
- turnBack()
- for l = 1, length do
- currentLength = length - l + 1
- kopat("forward")
- end
- turnBack()
- --Копать выше
- if h < height then
- for i = 1, 3 do
- kopat("up")
- end
- end
- end
- --Возврат назад по высоте
- for i = 1, ((height - 1) * 3) do
- kopat("down")
- end
- turtle.turnRight()
- if r < rows then
- for i = 1, (spaceBetweenRows + 1) do
- kopat("forward")
- turtle.digUp()
- turtle.digDown()
- end
- end
- turtle.turnLeft()
- end
- turtle.turnLeft()
- for i = 1, ((rows - 1) * (spaceBetweenRows + 1)) do
- kopat("forward")
- end
- kopat("down")
- if sunduk then
- turtle.turnLeft()
- for i = 1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnRight()
- end
- turtle.turnRight()
- text(2, 2, "Done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement