Update src/main/programs/turtle-roomCreator.lua
This commit is contained in:
parent
40ed219c10
commit
96de9b2d6f
@ -1,58 +1,51 @@
|
||||
-- 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
|
||||
turtle.dig()
|
||||
turtle.forward()
|
||||
end
|
||||
|
||||
-- If not the last row, return to the starting point
|
||||
-- Return to starting position of each row
|
||||
if w < width then
|
||||
-- Turning around
|
||||
if w % 2 == 0 then
|
||||
turtle.turnRight()
|
||||
else
|
||||
turtle.turnLeft()
|
||||
end
|
||||
-- Returning to the starting point
|
||||
for i = 1, depth do
|
||||
turtle.turnRight()
|
||||
turtle.turnRight()
|
||||
for d = 1, depth do
|
||||
turtle.forward()
|
||||
end
|
||||
-- Turning to the correct direction
|
||||
if w % 2 == 0 then
|
||||
turtle.turnLeft()
|
||||
else
|
||||
turtle.turnRight()
|
||||
end
|
||||
turtle.turnRight()
|
||||
turtle.turnRight()
|
||||
end
|
||||
end
|
||||
|
||||
-- Returning to the starting point of the layer and going up
|
||||
-- Go back to starting position of each layer and go up
|
||||
if h < height then
|
||||
-- Returning to the starting point
|
||||
if h % 2 == 0 then
|
||||
turtle.turnRight()
|
||||
for i = 1, width - 1 do
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.turnRight()
|
||||
turtle.turnLeft()
|
||||
else
|
||||
turtle.turnLeft()
|
||||
for i = 1, width - 1 do
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.turnLeft()
|
||||
turtle.turnRight()
|
||||
end
|
||||
for w = 1, width - 1 do
|
||||
turtle.forward()
|
||||
end
|
||||
if h % 2 == 0 then
|
||||
turtle.turnLeft()
|
||||
else
|
||||
turtle.turnRight()
|
||||
end
|
||||
|
||||
-- Going up
|
||||
turtle.digUp()
|
||||
turtle.up()
|
||||
end
|
||||
end
|
||||
-- Return to the starting position
|
||||
turtle.turnRight()
|
||||
turtle.turnRight()
|
||||
for h = 1, height - 1 do
|
||||
turtle.down()
|
||||
end
|
||||
for w = 1, width - 1 do
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.turnRight()
|
||||
turtle.turnRight()
|
||||
end
|
||||
|
||||
-- Retrieving parameters from input
|
||||
|
Loading…
Reference in New Issue
Block a user