diff --git a/compacting-storage.lua b/compacting-storage.lua index 3c96bfa..b3edf3f 100644 --- a/compacting-storage.lua +++ b/compacting-storage.lua @@ -46,12 +46,13 @@ function sum_items (inv) local result = {} for _, type in ipairs(ITEM_TYPES) do result[type] = {} + for _, form in ipairs(PRIORITY) do + result[type][form] = 0 + end end for slot, item in pairs(inv.list()) do local type, form = item.name:match".-:(%l-)_(%l*)" - if result[type][form] == nil then - result[type][form] = item.count - else + if type ~= nil and form ~= nil then result[type][form] = result[type][form] + item.count end end