Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Self.Count = function(itemid, container)
- if(container)then -- count specific container
- return Container.GetByName(container):CountItemsOfID(itemid) or 0
- end
- local value = 0
- local slots = {Self.Head, Self.Armor, Self.Legs, Self.Feet, Self.Amulet, Self.Weapon, Self.Ring, Self.Shield, Self.Ammo}
- for i = 1, #slots do -- count slots
- local slot = slots[i]()
- if(slot.id == itemid)then
- value = value + math.max(slot.count, 1)
- end
- end
- if(container == nil)then -- count everything
- local cont = Container.GetFirst()
- while (cont:isOpen()) do
- value = value + cont:CountItemsOfID(itemid)
- cont = cont:GetNext()
- end
- end
- return value
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement