Update src/main/programs/turtle-roomCreator.lua
This commit is contained in:
parent
567b4240c9
commit
ec7fc3c566
@ -1,60 +1,38 @@
|
|||||||
-- Function to dig a cuboid with given dimensions
|
|
||||||
function excavate(depth, width, height)
|
function excavate(depth, width, height)
|
||||||
|
-- Digging loop
|
||||||
for h = 1, height do
|
for h = 1, height do
|
||||||
|
-- Digging a layer
|
||||||
for w = 1, width do
|
for w = 1, width do
|
||||||
|
-- Digging a row
|
||||||
for d = 1, depth do
|
for d = 1, depth do
|
||||||
turtle.dig()
|
turtle.dig() -- Digging forward
|
||||||
turtle.forward()
|
turtle.forward() -- Moving forward
|
||||||
end
|
end
|
||||||
-- Return to starting position of each row
|
--move to start of row
|
||||||
if w < width then
|
for d = 1, depth do
|
||||||
turtle.back(depth)
|
turtle.back()
|
||||||
if w % 2 == 0 then
|
end
|
||||||
turtle.turnRight()
|
|
||||||
else
|
-- go to next row if not last row
|
||||||
turtle.turnLeft()
|
if w<width then
|
||||||
end
|
turtle.turnRight()
|
||||||
|
turtle.dig()
|
||||||
turtle.forward()
|
turtle.forward()
|
||||||
if w % 2 == 0 then
|
turte.turnLeft()
|
||||||
turtle.turnRight()
|
|
||||||
else
|
|
||||||
turtle.turnLeft()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Go back to starting position of each layer and go up
|
|
||||||
if h < height then
|
--move to start of layer
|
||||||
if h % 2 == 0 then
|
turtle.turnRight()
|
||||||
turtle.turnLeft()
|
for w = 1, width do
|
||||||
else
|
turtle.back()
|
||||||
turtle.turnRight()
|
end
|
||||||
end
|
turtle.turnLeft()
|
||||||
turtle.back(width * depth)
|
|
||||||
if h % 2 == 0 then
|
--go to next layer if not last layer
|
||||||
turtle.turnLeft()
|
if h<height then
|
||||||
else
|
turte.digUp()
|
||||||
turtle.turnRight()
|
|
||||||
end
|
|
||||||
turtle.up()
|
turtle.up()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Return to the starting position
|
end
|
||||||
turtle.back(height * width)
|
|
||||||
turtle.turnRight()
|
|
||||||
turtle.turnRight()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Retrieving parameters from input
|
|
||||||
local args = {...}
|
|
||||||
local depth = tonumber(args[1])
|
|
||||||
local width = tonumber(args[2])
|
|
||||||
local height = tonumber(args[3])
|
|
||||||
|
|
||||||
-- Validating input
|
|
||||||
if depth == nil or width == nil or height == nil then
|
|
||||||
print("Usage: excavate <depth> <width> <height>")
|
|
||||||
else
|
|
||||||
-- Excavating
|
|
||||||
excavate(depth, width, height)
|
|
||||||
print("Excavation completed!")
|
|
||||||
end
|
|
Loading…
Reference in New Issue
Block a user