Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = { ... }
- function digForward()
- while turtle.detect() do
- turtle.dig()
- end
- end
- function digUp()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- function digDown()
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- function forward(count)
- for i = 1, count do
- digForward(1)
- while not turtle.forward() do
- digForward(1)
- turtle.attack()
- end
- end
- end
- function up(count)
- for i = 1, count do
- digUp(1)
- while not turtle.up() do
- digUp(1)
- turtle.attackUp()
- end
- end
- end
- function down(count)
- for i = 1, count do
- digDown(1)
- while not turtle.down() do
- digDown(1)
- turtle.attackDown()
- end
- end
- end
- function turnLeft(count)
- for i = 1, count do
- turtle.turnLeft()
- end
- end
- function turnRight(count)
- for i = 1, count do
- turtle.turnRight()
- end
- end
- if #args ~= 3 then
- error("expected exactly 3 arguments (" .. #args .. " given) [turtle is standing in area and facing x, right is y and top is z args:[x,y,z]]")
- end
- local d = tonumber(args[1])
- local w = tonumber(args[2])
- local h = tonumber(args[3])
- function digModed(mode)
- if mode > 0 then digUp() end --height>1
- if mode > 1 then digDown() end --height=3
- end
- function digSurface(x, y, mode)
- if mode > 1 then up(1) end --height=3
- for y1 = 1, y do
- for x1 = 1, x - 1 do
- digModed(mode)
- forward(1)
- end
- digModed(mode)
- if y1 ~= y then
- if y1 % 2 == 1 then
- turnRight(1)
- forward(1)
- digModed(mode)
- turnRight(1)
- else
- turnLeft(1)
- forward(1)
- digModed(mode)
- turnLeft(1)
- end
- end
- end
- if mode > 1 then down(1) end --height=3
- end
- local mode = h % 3
- h = h / 3 - mode / 3
- mode=mode-1
- if mode==-1 then mode=2 end
- if mode ~= 2 then h = h + 1 end
- print("mode: ",mode)
- for h1 = 1, h do
- if h1 == h then
- print(1)
- digSurface(d, w, mode)
- else
- print(2)
- digSurface(d, w, 3)
- up(3)
- if w % 2 == 0 then
- turnRight(1)
- local p = d
- d = w
- w = p
- else
- turnLeft(2)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement