digroom update
This commit is contained in:
parent
109c1223c7
commit
d471077330
29
digroom.lua
29
digroom.lua
@ -1,14 +1,18 @@
|
|||||||
-- local coordinates!
|
|
||||||
local tArgs = { ... }
|
local tArgs = { ... }
|
||||||
local x = tArgs[1]
|
if table.maxn(tArgs) ~= 3 then
|
||||||
local y = tArgs[2]
|
print("This program digs a room in front of the turtle to the right.")
|
||||||
local z = tArgs[3]
|
print("Arguments: width, length, height.")
|
||||||
local fuel = 16
|
return
|
||||||
|
end
|
||||||
|
local width = tArgs[1]
|
||||||
|
local length = tArgs[2]
|
||||||
|
local height = tArgs[3]
|
||||||
local up = true
|
local up = true
|
||||||
local fw = false
|
local fw = false
|
||||||
|
print("Digging room with", width, "width,", length, "length and", height, "height.")
|
||||||
|
|
||||||
local function digUp()
|
local function digUp()
|
||||||
for i = 2, z do
|
for i = 2, height do
|
||||||
while not turtle.up() do
|
while not turtle.up() do
|
||||||
turtle.digUp()
|
turtle.digUp()
|
||||||
end
|
end
|
||||||
@ -16,7 +20,7 @@ local function digUp()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function digDown()
|
local function digDown()
|
||||||
for i = 2, z do
|
for i = 2, height do
|
||||||
while not turtle.down() do
|
while not turtle.down() do
|
||||||
turtle.digDown()
|
turtle.digDown()
|
||||||
end
|
end
|
||||||
@ -40,25 +44,26 @@ end
|
|||||||
|
|
||||||
local function turn()
|
local function turn()
|
||||||
if fw then
|
if fw then
|
||||||
turtle.turnRight()
|
|
||||||
else
|
|
||||||
turtle.turnLeft()
|
turtle.turnLeft()
|
||||||
|
else
|
||||||
|
turtle.turnRight()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function refuel()
|
local function refuel()
|
||||||
if turtle.getFuelLevel() <= 4 * z then
|
if turtle.getFuelLevel() <= 4 * height then
|
||||||
if not turtle.refuel() then
|
if not turtle.refuel() then
|
||||||
print("No fuel!")
|
print("No fuel!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, x do
|
refuel()
|
||||||
|
for i = 1, width do
|
||||||
digFw()
|
digFw()
|
||||||
turn()
|
turn()
|
||||||
fw = not fw
|
fw = not fw
|
||||||
for j = 2, y do
|
for j = 2, length do
|
||||||
digVertical()
|
digVertical()
|
||||||
digFw()
|
digFw()
|
||||||
refuel()
|
refuel()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user