ComputerCraft/digroom.lua
2022-06-30 11:05:00 +02:00

69 lines
1.0 KiB
Lua

-- local coordinates!
local tArgs = { ... }
local x = tArgs[1]
local y = tArgs[2]
local z = tArgs[3]
local fuel = 16
local up = true
local fw = false
local function digUp()
for i = 2, z do
while not turtle.up() do
turtle.digUp()
end
end
end
local function digDown()
for i = 2, z do
while not turtle.down() do
turtle.digDown()
end
end
end
local function digVertical()
if up then
digUp()
else
digDown()
end
up = not up
end
local function digFw()
while not turtle.forward() do
turtle.dig()
end
end
local function turn()
if fw then
turtle.turnRight()
else
turtle.turnLeft()
end
end
local function refuel()
if turtle.getFuelLevel() <= 4 * z then
if not turtle.refuel() then
print("No fuel!")
end
end
end
for i = 1, x do
digFw()
turn()
fw = not fw
for j = 2, y do
digVertical()
digFw()
refuel()
end
digVertical()
turn()
end