Skip to content

Instantly share code, notes, and snippets.

@joelhelbling
Last active January 20, 2016 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelhelbling/bdbe35f140c41ad9afe3 to your computer and use it in GitHub Desktop.
Save joelhelbling/bdbe35f140c41ad9afe3 to your computer and use it in GitHub Desktop.
local fill_inv
fill_inv = function()
for i = 1, 16 do
turtle.select(i)
turtle.suck()
end
end
local dump_inv
dump_inv = function()
for i = 1, 16 do
turtle.select(i)
turtle.dropDown()
end
end
local running = true
print("Good day to you! I'm ready to ferry your goods between two stations.")
while running do
if turtle.detect() then
print("Dumping inventory...")
dump_inv()
if turtle.getFuelLevel() < 1000 then
print("Fuel low, refueling...")
turtle.suckUp()
turtle.refuel()
end
io.write("Refueled. Fuel level: ")
print(turtle.getFuelLevel())
print("Filling inventory...")
fill_inv()
turtle.turnLeft()
turtle.turnLeft()
end
print("And I'm off!")
while not turtle.detect() do
turtle.forward()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment