Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local distance = 150
- function init()
- print("Init")
- resetSignals()
- print("Fuel = " .. turtle.getFuelLevel())
- while turtle.getFuelLevel() < 500 do
- print("Looking for Fuel")
- for slot = 1,16 do
- if turtle.getFuelLevel() < 500 then
- turtle.select(slot)
- repeat
- until turtle.refuel(1) == false or turtle.getFuelLevel() > 500
- end
- end
- print("Trying to get fuel from interface")
- repeat
- until turtle.up() == false
- useInterface()
- print("Fuel = " .. turtle.getFuelLevel())
- end
- end
- function fillFuel()
- while turtle.getFuelLevel() < 500 do
- turtle.select(1)
- turtle.refuel(20)
- print("Fuel = " .. turtle.getFuelLevel())
- sleep(5)
- end
- end
- function findInterface()
- while turtle.detectUp() == false do
- turtle.up()
- end
- end
- function useInterface()
- for slot = 1,16 do
- turtle.select(slot)
- turtle.dropUp()
- end
- turtle.select(1)
- turtle.suckUp()
- end
- function chop()
- for x = 1, distance do
- turtle.suckDown()
- turtle.digDown()
- turtle.down()
- end
- end
- function waitForAll()
- print("Waiting for all turtles to be ready")
- --wait for a pass on a signal from all directions
- repeat
- sleep(1)
- until redstone.getInput("left")
- redstone.setOutput("right", true)
- print("Left Ready")
- repeat
- sleep(1)
- until redstone.getInput("right")
- redstone.setOutput("left", true)
- print("Right Ready")
- repeat
- sleep(1)
- until redstone.getInput("front")
- redstone.setOutput("back", true)
- print("Front Ready")
- repeat
- sleep(1)
- until redstone.getInput("back")
- redstone.setOutput("front", true)
- print("Back Ready")
- --wait to ensure all others get the message
- print("All Ready - Prepare to Move")
- sleep(10)
- end
- function resetSignals()
- redstone.setOutput("left", false)
- redstone.setOutput("right", false)
- redstone.setOutput("front", false)
- redstone.setOutput("back", false)
- end
- --Start main code
- init()
- while true do
- --Stop emitting ready status
- resetSignals()
- --move up until we find the interface
- findInterface()
- --unload and collect fuel
- useInterface()
- --Make sure we have some fuel to move
- fillFuel()
- --check that everyone around us is ready
- waitForAll()
- --chop down a line
- chop()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement