Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- slot = 1
- place = false
- function placeUp()
- if place then
- if turtle.getItemCount(slot) == 0 then
- slot = slot + 1
- end
- turtle.select(slot)
- turtle.placeUp()
- end
- end
- function placeBehind()
- if place then
- if turtle.getItemCount(slot) == 0 then
- slot = slot + 1
- end
- turtle.select(slot)
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- function goForward ()
- placeUp()
- turtle.dig()
- turtle.forward()
- end
- function goUp()
- placeBehind()
- turtle.digUp();
- turtle.up();
- end
- function goDown()
- placeBehind()
- turtle.digDown();
- turtle.down();
- end
- function goLeft()
- turtle.turnLeft()
- goForward()
- turtle.turnLeft()
- end
- function goRight()
- turtle.turnRight()
- goForward()
- turtle.turnRight()
- end
- local args = { ... }
- if #args < 4 then
- print("Parameters: <size> <depth> <place> <forward>")
- else
- local fn = tonumber(args[1])
- local down = tonumber(args[2])
- local needToGoLeft = false
- local needToGoDown = false
- if (args[3] == "1") then
- place = true
- end
- if args[4] == "1" then
- local i = 0
- turtle.digDown()
- turtle.down()
- while i < down do
- local l = 0
- while l < fn do
- local f = 1
- while f < fn do
- goForward()
- f = f + 1
- end
- l = l + 1
- if (l < fn) then
- if (needToGoLeft) then
- goLeft()
- needToGoLeft = false
- else
- goRight()
- needToGoLeft = true
- end
- end
- end
- i = i + 1
- if i < down then
- placeUp()
- turtle.digDown()
- turtle.down()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- else
- local i = 0
- while i < down do
- local l = 0
- while l < fn do
- local f = 1
- while f < fn do
- if needToGoDown then
- goDown()
- else
- goUp()
- end
- f = f + 1
- end
- if needToGoDown then
- needToGoDown = false
- else
- needToGoDown = true
- end
- placeBehind()
- l = l + 1
- if (l < fn) then
- if (needToGoLeft) then
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- else
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- end
- i = i + 1
- if (needToGoLeft) then
- needToGoLeft = false
- else
- needToGoLeft = true
- end
- if i < down then
- turtle.dig()
- turtle.forward()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment