Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------- Variables ----------
- chest = 14
- torch = 15
- fuel = 16
- maxFuel = 100
- --------- Functions ----------
- function checkFuel()
- print(turtle.getFuelLevel())
- if turtle.getFuelLevel() < 1 then
- print('Refueling')
- refuel()
- end
- end
- function refuel()
- turtle.select(16)
- while turtle.getItemCount(fuel) > 0 and turtle.getFuelLevel() < maxFuel do
- turtle.refuel(1)
- end
- end
- function forward()
- checkFuel()
- while not turtle.forward() do
- turtle.dig()
- end
- end
- function clearBlocks()
- while turtle.detectUp() or turtle.detectDown() do
- turtle.digUp()
- turtle.digDown()
- end
- end
- function left()
- turtle.turnLeft()
- turtle.dig()
- forward()
- end
- function turnAround()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function right()
- turtle.turnRight()
- turtle.dig()
- forward()
- end
- function isFull()
- for i = 1,16 do
- if turtle.getItemCount(i) == 0 then
- return false
- end
- end
- return true
- end
- function returnHome()
- turnAround()
- turtle.select(chest)
- while not turtle.compare() do
- forward()
- end
- for i=1, 12, 1 do
- turtle.select(i)
- turtle.drop()
- end
- turnAround()
- while not turtle.detect() do
- forward()
- end
- end
- function dropOffCheck()
- if isFull() then
- returnHome()
- end
- end
- function placeTorch()
- turtle.turnRight()
- turtle.select(torch)
- turtle.place()
- turtle.turnLeft()
- end
- --------- Execution ----------
- lastTorch = 6
- while true do
- dropOffCheck()
- if lastTorch > 5 then
- placeTorch()
- lastTorch=0
- end
- forward()
- clearBlocks()
- left()
- clearBlocks()
- turnAround()
- forward()
- forward()
- clearBlocks()
- turnAround()
- forward()
- turtle.turnRight()
- lastTorch = lastTorch+1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement