summaryrefslogtreecommitdiff
path: root/refuel.lua
blob: 6d873fdbae60772c77725c0c64ef12ca9edd8301 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local function hasFuelInStorage(storage)
	-- TODO check the type of items
	for _, _ in pairs(storage.list()) do
		return true
	end

	return false
end

local function refuel()
	local storage =	peripheral.wrap("front")
	while (turtle.getFuelLimit() > turtle.getFuelLevel() and hasFuelInStorage(storage)) do
		turtle.suck()
		turtle.refuel()
	end

	turtle.drop()
end

return { refuel = refuel }