Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --3 high tunnel program
- -- takes length, l, r, m as argument for left, right or middle line
- -- fixes walls and ceiling
- args = { ... }
- length = tonumber(args[1])
- side = args[2]
- function refill()
- if turtle.getItemCount(1) == 0 then
- for s = 16,2,-1 do
- turtle.select(s)
- turtle.transferTo(1)
- end
- turtle.select(1)
- end
- end
- function leftWall()
- turtle.turnLeft()
- if not turtle.detect() then
- refill()
- turtle.place()
- end
- turtle.turnRight()
- end
- function rightWall()
- turtle.turnRight()
- if not turtle.detect() then
- refill()
- turtle.place()
- end
- turtle.turnLeft()
- end
- function doFloor()
- if not turtle.detectDown() then
- refill()
- turtle.placeDown()
- end
- end
- function doCeiling()
- if not turtle.detectUp() then
- refill()
- turtle.placeUp()
- end
- end
- function goUp()
- if turtle.detectUp() then
- turtle.digUp()
- end
- while not turtle.up() do
- sleep(1)
- end
- end
- function goDown()
- if turtle.detectDown() then
- turtle.digDown()
- end
- while not turtle.down() do
- sleep(1)
- end
- end
- function goForward()
- if turtle.detect() then
- turtle.dig()
- end
- while not turtle.forward() do
- sleep(1)
- end
- end
- for i = 1,length do
- --floor
- doFloor()
- for h = 1,3 do
- --walls
- if side == "l" then
- leftWall()
- elseif side == "r" then
- rightWall()
- end
- -- go up
- if h<3 then
- goUp()
- end
- end
- doCeiling()
- for h = 1,2 do
- goDown()
- end
- if i < length then
- goForward()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment