Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Modified Direwolf20's refueling and going home code to turn the turtle
- -- Modified by Richard Reigens 10/12/2013
- local fuel, slot
- slot = 1
- shell.run("goto.lua", "381", "62", "564") -- Sends turtle to its home position to refuel
- -- goto.lua is goto code from PhyscoKillerMonkey post at http://www.computercraft.info/forums2/index.php?/topic/5665-wireless-goto-program-for-gps-turtles/page__fromsearch__1
- -- coordinates can be changed to anything
- print("I am Home")
- for i = 1, 4 do --[modified] Turns turtle to face the chest "or what ever item is in front of home position"
- if turtle.detect() == false then
- turtle.turnRight()
- else
- break
- end
- end
- fuel = turtle.getFuelLevel() -- Checks Fuel
- print("Fuel Level: "..fuel)
- if (fuel < 100) then -- If Fuel is low "less then 100" then it grabs fuel from chest and refuels
- print("Refueling...")
- for i = 1, 16 do
- if turtle.getItemCount(i) == 0 then
- turtle.select(i)
- slot = i
- break
- end
- end
- turtle.suck()
- turtle.drop(turtle.getItemCount(slot) - 32) -- only grabs 32 fuel
- if turtle.refuel() then
- print("Fueled up Successfully")
- print("Fuel Level is now "..turtle.getFuelLevel())
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement