Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local fuel = 0
- function setFuelLevel(min)
- fuel = min
- end
- function getMinFuel()
- return fuel
- end
- function isFull()
- for i = 1,16 do
- if turtle.getItemCount(i) == 0 then
- return false
- end
- end
- return true
- end
- function refuel()
- local f = turtle.getFuelLevel()
- if f < fuel then
- local count = 1
- turtle.select(count)
- repeat
- f = turtle.getFuelLevel()
- if not turtle.refuel(1) then
- count = count + 1
- if count > 16 then return -1 end
- turtle.select(count)
- --turtle.select(
- --(turtle.getSelectedSlot() < 16 and turtle.getSelectedSlot()+1)
- --or 1)
- end
- until f >= fuel
- return 1 -- fueling success
- end
- return 0 --no need to refuel
- end
- function ret() --stands for return,
- --as in return to base
- if isFull() or refuel() == -1 then
- return true
- end
- return false
- end
- function idle()
- if isFull() then
- print("Inventory is full, press q to end")
- local t = read()
- if t == "q" or t == "Q" then return -1 end
- idle()
- end
- if refuel() == - 1 then
- print("Need more fuel")
- print(turtle.getFuelLevel())
- print("Press q to end")
- local t = read()
- if t == "q" or t == "Q" then return -1 end
- idle()
- end
- return 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement