Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arg = {...}
- local function turnLeft(num)
- for i = 1, num do
- turtle.turnLeft()
- end
- end
- function loop()
- if #arg > 2 then
- w = tonumber(arg[1])
- h = tonumber(arg[2])
- l = tonumber(arg[3])
- local x = 0
- local y = 0
- local z = 0
- local steps = 0
- orientation = getOrientation()
- while steps < w * h * l do
- if (orientation ~= 3) then
- end
- if (x < w - 1) then
- turtle.dig()
- turtle.forward()
- x = x + 1
- steps = steps + 1
- else
- if (z < l - 1) then
- if (z % 2 == 0) then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- turtle.dig()
- turtle.forward()
- steps = steps + 1
- if (z % 2 == 0) then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- x = 0
- z = z + 1
- else
- if (y < h - 1) then
- turnLeft(3)
- turtle.digDown()
- turtle.down()
- steps = steps + 1
- x = 0
- z = 0
- y = y + 1
- else
- break
- end
- end
- end
- end
- end
- end
- function getOrientation()
- loc1 = vector.new(gps.locate(2, false))
- steps = 1
- if (not turtle.forward()) then
- for i = 1, 6 do
- steps = steps + 1
- if (not turtle.forward()) then
- turtle.dig()
- else
- break
- end
- end
- end
- loc2 = vector.new(gps.locate(2, false))
- turnLeft(2)
- turtle.forward(2)
- turnLeft(2)
- heading = loc2 - loc1
- return ((heading.x + math.abs(heading.x) * 2) + (heading.z + math.abs(heading.z) * 3))
- end
- loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement