summaryrefslogtreecommitdiff
path: root/inv_utils.lua
blob: 9a6e280be651efcaa0b1d1df14f0fecb40c805f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
local function hasItemsInStorage(storage)
	for _, _ in pairs(storage.list()) do
		return true
	end

	return false
end

local function hasItemsInTurtle()
	for ii = 1, 16 do
		if turtle.getItemCount(ii) > 0 then
			return true
		end
	end

	return false
end

local function getEmptySlotInStorage(storage)
	return 5 -- TODO
end

local function swapSlotsInStorage(storage, slotA, slotB)
	local emptySlot = getEmptySlotInStorage(storage)
	storage.pushItems(peripheral.getName(storage), slotA, nil, emptySlot)
	storage.pushItems(peripheral.getName(storage), slotB, nil, slotA)
	storage.pushItems(peripheral.getName(storage), emptySlot, nil, slotB)
end


return { hasItemsInStorage = hasItemsInStorage, hasItemsInTurtle = hasItemsInTurtle, swapSlotsInStorage = swapSlotsInStorage }