Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local location = ""
- function teleport()
- tp = peripheral.wrap("bottom")
- tp.teleport()
- end
- function checkFull()
- greader = peripheral.wrap("right")
- data = greader.get()
- while not data["Full Energt"] do
- sleep(2)
- data=greader.get()
- end
- turtle.dig()
- end
- function checkEmpty()
- greader=peripheral.wrap("right")
- data = greader.get()
- while not data["No Energy"] do
- sleep(2)
- data = greader.get()
- end
- turtle.dig()
- end
- function checkLoc()
- loc = turtle.detectUp()
- if loc == true then
- print("I am at the quarry")
- location = "Quarry"
- else
- print("I am at the charge station")
- location = "Charging"
- end
- end
- function getFuel()
- turtle.turnRight()
- for i = 1, 9 do turtle.forward() end
- turtle.turnLeft()
- for i = 1, 6 do turtle.forward() end
- turtle.suck()
- turtle.refuel()
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1, 6 do turtle.forward() end
- turtle.turnRight()
- for i = 1, 9 do turtle.forward() end
- turtle.turnRight()
- end
- function checkFuel()
- fuel = turtle.getFuelLevel()
- print("My fuel level:"..tostring(fuel))
- if fuel < 2500 then
- print("I need fuel")
- getFuel()
- print("My fuel level:"..tostring(turtle.getFuelLevel()))
- end
- end
- checkLoc()
- if location == "Quarry" then
- turtle.turnRight()
- turtle.place()
- checkEmpty()
- teleport()
- else
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.place()
- checkFuel()
- checkFull()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- teleport()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement