Hi Guys, so I made a simple loop that loops through a table but for some reason, it skips it.
Code -
function Inventory:AddItem(Item, amount)
for i, v in pairs(self) do
if v.isOccupied == false then
print(i)
v.isOccupied = true
v.item = Item
break
end
end
self (the table) has 3 values but it’s skipping the 2nd one. Those 3 tables inside self are -
["1"] = {
isOccupied = false, -- checks if the slot is occupied
item = nil, -- what item is inside the slot
amount = 0
},
["2"] = {
isOccupied = false, -- checks if the slot is occupied
item = nil, -- what item is inside the slot
amount = 0
},
["3"] = {
isOccupied = false, -- checks if the slot is occupied
item = nil, -- what item is inside the slot
amount = 0
}
}
Any help is appreciated, thanks