120 lines
2.7 KiB
Lua
120 lines
2.7 KiB
Lua
|
local t = turtle
|
||
|
|
||
|
print("Length: ")
|
||
|
local LENGTH = tonumber(read())
|
||
|
print("Width: ")
|
||
|
local WIDTH = tonumber(read())
|
||
|
print("Height: ")
|
||
|
local HEIGHT = tonumber(read())
|
||
|
|
||
|
---------------------------
|
||
|
|
||
|
local function detectedDig()
|
||
|
while t.detect() == true do
|
||
|
t.detect()
|
||
|
t.dig()
|
||
|
end
|
||
|
end
|
||
|
|
||
|
---------------------------
|
||
|
for n=1,HEIGHT do
|
||
|
for i=1,WIDTH do
|
||
|
for j=2,LENGTH do
|
||
|
detectedDig() ----
|
||
|
t.forward()
|
||
|
end
|
||
|
|
||
|
if WIDTH%2 ~= 0 then
|
||
|
if i+1<=WIDTH then
|
||
|
if i%2 == 0 then
|
||
|
t.turnLeft()
|
||
|
detectedDig() ----
|
||
|
t.forward()
|
||
|
t.turnLeft()
|
||
|
elseif i%2 ~= 0 then
|
||
|
t.turnRight()
|
||
|
detectedDig() -----
|
||
|
t.forward()
|
||
|
t.turnRight()
|
||
|
end
|
||
|
end
|
||
|
elseif WIDTH%2 == 0 then
|
||
|
if n%2 == 0 then
|
||
|
if i+1<=WIDTH then
|
||
|
if i%2 ~= 0 then
|
||
|
t.turnLeft()
|
||
|
detectedDig() -----
|
||
|
t.forward()
|
||
|
t.turnLeft()
|
||
|
elseif i%2 == 0 then
|
||
|
t.turnRight()
|
||
|
detectedDig() -----
|
||
|
t.forward()
|
||
|
t.turnRight()
|
||
|
end
|
||
|
end
|
||
|
elseif n%2 ~= 0 then
|
||
|
if i+1<=WIDTH then
|
||
|
if i%2 == 0 then
|
||
|
t.turnLeft()
|
||
|
detectedDig() -----
|
||
|
t.forward()
|
||
|
t.turnLeft()
|
||
|
elseif i%2 ~= 0 then
|
||
|
t.turnRight()
|
||
|
detectedDig() -----
|
||
|
t.forward()
|
||
|
t.turnRight()
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
if n<HEIGHT then
|
||
|
t.digUp()
|
||
|
t.up()
|
||
|
t.turnLeft()
|
||
|
t.turnLeft()
|
||
|
end
|
||
|
|
||
|
end
|
||
|
----------------------------
|
||
|
if HEIGHT%2 == 0 then
|
||
|
for i=2,HEIGHT do
|
||
|
t.down()
|
||
|
end
|
||
|
end
|
||
|
|
||
|
if HEIGHT%2 ~= 0 then
|
||
|
if WIDTH%2 == 0 then
|
||
|
t.turnRight()
|
||
|
|
||
|
for i=2,WIDTH do
|
||
|
t.forward()
|
||
|
end
|
||
|
|
||
|
t.turnLeft()
|
||
|
|
||
|
for i=2,HEIGHT do
|
||
|
t.down()
|
||
|
end
|
||
|
|
||
|
|
||
|
elseif WIDTH%2 ~= 0 then
|
||
|
t.turnLeft()
|
||
|
|
||
|
for i=2,WIDTH do
|
||
|
t.forward()
|
||
|
end
|
||
|
|
||
|
t.turnLeft()
|
||
|
|
||
|
for i=2,LENGTH do
|
||
|
t.forward()
|
||
|
end
|
||
|
|
||
|
for i=2,HEIGHT do
|
||
|
t.down()
|
||
|
end
|
||
|
end
|
||
|
end
|