Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- length = 0
- width = 0
- depth = 0
- --functions--
- function clr()
- term.clear()
- term.setCursorPos(1,1)
- end
- function forward(units)
- for i=0, units do
- while (turtle.forward() == false) do
- turtle.dig()
- turtle.attack()
- end
- if (facing == 0) then
- currentY = currentY + 1
- elseif (facing == 1) then
- currentX = currentX + 1
- elseif (facing == 2) then
- currentY = currentY - 1
- elseif (facing == 3) then
- currentX = currentX - 1
- end
- if (turtle.getItemCount(12) == 0) then
- dump(currentX, currentY, currentZ, facing)
- end
- end
- end
- function right(units)
- for i=0, units do
- turtle.turnRight()
- facing = facing + 1
- if (facing > 3) then
- facing = 0
- end
- end
- end
- function left(units)
- for i=0, units do
- turtle.turnLeft()
- facing = facing - 1
- if (facing < 0) then
- facing = 3
- end
- end
- end
- function up(units)
- for i=0, units do
- while (turtle.up() == false) do
- turtle.digUp()
- turtle.attackUp()
- end
- currentZ = currentZ + 1
- end
- end
- function down(units)
- for i=0, units do
- while (turtle.down() == false) do
- turtle.digDown()
- turtle.attackDown()
- end
- currentZ = currentZ - 1
- end
- end
- function dump(xPos, yPos, zPos, dir)
- while (facing ~= 2) do
- right(1)
- end
- up(zPos)
- forward(yPos)
- if (xPos > 0) then
- right(1)
- forward(xPos)
- left(1)
- elseif (xPos < 0) then
- left(1)
- forward(-xPos)
- right(1)
- end
- for i=1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- if (dir ~= -1) then
- right(2)
- if (xPos > 0) then
- right(1)
- forward(xPos)
- left(1)
- elseif (xPos < 0) then
- left(1)
- forward(-xPos)
- right(1)
- end
- forward(yPos)
- down(zPos)
- while (facing ~= dir) do
- right(1)
- end
- end
- end
- function dump()
- for i=1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- end
- --variables--
- currentX = 0
- currentY = 0
- currentZ = 0
- facing = 0 --0 relative north, 1 relative east, 2 relative south, 3 relative west
- move = 0 --determines whether to go left or right
- --main--
- --using standard zig zag, goes down 1 after each layer (will include offset later?)
- for d=0, depth do
- for l=0, length do
- if (move % 2 == 0) then
- left(1)
- forward(width)
- right(1)
- else
- right(1)
- forward(width)
- left(1)
- end
- if (l ~= length) then
- forward(1)
- end
- move = move + 1
- end
- down(1)
- right(2)
- end
- dump(currentX, currentY, currentZ, -1)
- print("Done!")
Advertisement
Add Comment
Please, Sign In to add comment