summaryrefslogtreecommitdiff
path: root/inv_utils.lua
blob: 872647df8bb3bf94e988dae5524fa2fe8c5f9f48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local function hasItemsInStorage(storage)
	for _, _ in pairs(storage.list()) do
		return true
	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, swapSlotsInStorage = swapSlotsInStorage }