Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- if #tArgs == 0 then
- print( "Usage: wallup <length> [depth] " )
- return
- end
- local length = tonumber( tArgs[1] )
- if length < 2 then
- print( "wall length must be > 2" )
- return
- end
- local depth = 256
- if #tArgs >= 2 then
- depth = tonumber( tArgs[2] )
- if depth < 1 then
- print( "wall depth must be positive" )
- return
- end
- end
- local function digForward()
- while (turtle.detect()) do
- turtle.dig()
- sleep(0.2)
- end
- end
- local function digUp()
- while (turtle.detectUp()) do
- turtle.digUp()
- sleep(0.2)
- end
- end
- local relY = 0
- local function tryDown()
- if (turtle.detectDown()) then
- turtle.digDown()
- end
- if (turtle.detectDown()) then
- return false
- end
- if (turtle.down()) then
- relY = relY-1
- return true
- else
- return false
- end
- end
- local function tryUp()
- while (turtle.detectUp()) do
- turtle.digUp()
- end
- if (turtle.up()) then
- relY = relY + 1
- return true
- else
- return false
- end
- end
- local function suckAll()
- while turtle.suck() do
- end
- end
- local function wallLayer()
- for side=1,4 do
- for i=1,(length) do
- turtle.turnLeft()
- suckAll()
- if not turtle.compare() then
- digForward()
- suckAll()
- turtle.place()
- end
- turtle.turnRight()
- if i< length then
- digForward()
- turtle.forward()
- end
- end
- turtle.turnRight()
- end
- end
- local function returnToTop()
- while relY < 0 do
- local canUp = tryUp()
- if not canUp then
- break
- end
- end
- end
- turtle.select(1)
- for curDepth=1,depth do
- wallLayer()
- if curDepth < depth then
- local canDown = tryDown()
- if not canDown then
- break
- end
- end
- end
- returnToTop()
Advertisement
Add Comment
Please, Sign In to add comment