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 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() -- Digging forward
|
turtle.dig()
|
||||||
turtle.forward() -- Moving forward
|
turtle.forward()
|
||||||
end
|
end
|
||||||
|
-- Return to starting position of each row
|
||||||
-- If not the last row, return to the starting point
|
|
||||||
if w < width then
|
if w < width then
|
||||||
-- Turning around
|
turtle.turnRight()
|
||||||
if w % 2 == 0 then
|
turtle.turnRight()
|
||||||
turtle.turnRight()
|
for d = 1, depth do
|
||||||
else
|
|
||||||
turtle.turnLeft()
|
|
||||||
end
|
|
||||||
-- Returning to the starting point
|
|
||||||
for i = 1, depth do
|
|
||||||
turtle.forward()
|
turtle.forward()
|
||||||
end
|
end
|
||||||
-- Turning to the correct direction
|
turtle.turnRight()
|
||||||
if w % 2 == 0 then
|
turtle.turnRight()
|
||||||
turtle.turnLeft()
|
|
||||||
else
|
|
||||||
turtle.turnRight()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Go back to starting position of each layer and go up
|
||||||
-- Returning to the starting point of the layer and going up
|
|
||||||
if h < height then
|
if h < height then
|
||||||
-- Returning to the starting point
|
|
||||||
if h % 2 == 0 then
|
if h % 2 == 0 then
|
||||||
turtle.turnRight()
|
turtle.turnLeft()
|
||||||
for i = 1, width - 1 do
|
|
||||||
turtle.forward()
|
|
||||||
end
|
|
||||||
turtle.turnRight()
|
|
||||||
else
|
else
|
||||||
turtle.turnLeft()
|
turtle.turnRight()
|
||||||
for i = 1, width - 1 do
|
end
|
||||||
turtle.forward()
|
for w = 1, width - 1 do
|
||||||
end
|
turtle.forward()
|
||||||
turtle.turnLeft()
|
end
|
||||||
|
if h % 2 == 0 then
|
||||||
|
turtle.turnLeft()
|
||||||
|
else
|
||||||
|
turtle.turnRight()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Going up
|
|
||||||
turtle.digUp()
|
|
||||||
turtle.up()
|
turtle.up()
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
-- Retrieving parameters from input
|
-- Retrieving parameters from input
|
||||||
|
Loading…
Reference in New Issue
Block a user