Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function placeFloorBlock()
- if not turtle.detectDown() then
- turtle.select(3)
- if turtle.placeDown() then
- return true
- end
- print("Placing floor failed")
- return false
- end
- end
- function fuel()
- if turtle.getFuelLevel() < 25 then
- turtle.select(1)
- if turtle.refuel(1) then
- return true
- end
- print ("Refuelling failed")
- return false
- end
- end
- function DigAndMove()
- while not turtle.forward() do
- if not turtle.dig() then
- turtle.attack()
- end
- end
- while turtle.detectUp() do
- turtle.digUp()
- sleep(0.5)
- end
- placeFloorBlock()
- end
- function turnAround()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function placeTorch()
- turtle.turnRight()
- turtle.dig()
- if not turtle.detect() then
- turtle.select(2)
- if turtle.place() then
- turtle.turnLeft()
- return true
- end
- end
- print("Place torch failed")
- turtle.turnLeft()
- return false
- end
- local tArgs = { ... }
- local length = tonumber(tArgs[1])
- local moveBack = 0
- local blocksMovedForward = 0
- while blocksMovedForward < length do
- fuel()
- DigAndMove()
- blocksMovedForward = blocksMovedForward + 1
- -- add torches
- if (blocksMovedForward % 8) == 0 then
- placeTorch()
- end
- if blocksMovedForward == length then
- turnAround()
- while moveBack < length do
- fuel()
- turtle.forward()
- moveBack = moveBack + 1
- end
- end
- end
- turnAround()
Advertisement
Add Comment
Please, Sign In to add comment