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)
|
||||
-- Digging loop
|
||||
for h = 1, height do
|
||||
-- Digging a layer
|
||||
for w = 1, width do
|
||||
-- Digging a row
|
||||
for d = 1, depth do
|
||||
turtle.dig() -- Digging forward
|
||||
turtle.forward() -- Moving forward
|
||||
end
|
||||
--move to start of row
|
||||
for d = 1, depth do
|
||||
turtle.back()
|
||||
end
|
||||
|
||||
-- go to next row if not last row
|
||||
if w<width then
|
||||
turtle.turnRight()
|
||||
turtle.dig()
|
||||
turtle.forward()
|
||||
turte.turnLeft()
|
||||
end
|
||||
-- Return to starting position of each row
|
||||
if w < width then
|
||||
turtle.back(depth)
|
||||
if w % 2 == 0 then
|
||||
end
|
||||
|
||||
--move to start of layer
|
||||
turtle.turnRight()
|
||||
else
|
||||
for w = 1, width do
|
||||
turtle.back()
|
||||
end
|
||||
turtle.turnLeft()
|
||||
end
|
||||
turtle.forward()
|
||||
if w % 2 == 0 then
|
||||
turtle.turnRight()
|
||||
else
|
||||
turtle.turnLeft()
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Go back to starting position of each layer and go up
|
||||
|
||||
--go to next layer if not last layer
|
||||
if h<height then
|
||||
if h % 2 == 0 then
|
||||
turtle.turnLeft()
|
||||
else
|
||||
turtle.turnRight()
|
||||
end
|
||||
turtle.back(width * depth)
|
||||
if h % 2 == 0 then
|
||||
turtle.turnLeft()
|
||||
else
|
||||
turtle.turnRight()
|
||||
end
|
||||
turte.digUp()
|
||||
turtle.up()
|
||||
end
|
||||
end
|
||||
-- Return to the starting position
|
||||
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