digroom
This commit is contained in:
parent
48eb260fbb
commit
a008309155
68
digroom.lua
Normal file
68
digroom.lua
Normal file
@ -0,0 +1,68 @@
|
||||
-- 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
|
||||
Loading…
x
Reference in New Issue
Block a user