Skip to content

Commit eada87b

Browse files
committed
accept an empty item instead of false
1 parent 9ec19a6 commit eada87b

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

equipment/equipment.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ local equipment = {}
3434
equipment.equip = function(_, slot_items)
3535
local count = 0
3636
local items = {}
37-
for slot, item in pairs(slot_items) do
38-
if slot >= 0 and slot <= 15 then
39-
local bag = item and item.bag or 0
40-
local index = item and item.index or 0
37+
for i = 0, 15 do
38+
local item = slot_items[i]
39+
if item then
40+
local bag = item.bag
41+
local index = item.index
4142
assert(equippable[bag], 'Cannot equip from this bag (bag = ' .. bag .. ')')
42-
assert(not item or item.id ~= 0, 'Cannot equip from an empty bag slot (bag = ' .. bag .. ', index = ' .. index .. ')')
43-
items[count] = {bag_index = index, slot_id = slot, bag_id = bag}
43+
assert(bag == 0 and index == 0 or item.id ~= 0, 'Cannot equip from an empty bag slot (bag = ' .. bag .. ', index = ' .. index .. ')')
44+
items[count] = {bag_index = index, slot_id = i, bag_id = bag}
4445
count = count + 1
4546
end
4647
end

0 commit comments

Comments
 (0)