feat: add item removal functions

This commit is contained in:
Kazhnuz 2021-03-12 20:54:45 +01:00
parent 3353ae7d37
commit 7b375bfed2
2 changed files with 19 additions and 0 deletions

View file

@ -51,6 +51,13 @@ function LootManager:addItem(type, item, number)
end
end
function LootManager:removeItem(type, item, number)
local pocket = self:getPocketByName(type)
if (itemutils.itemExists(type, item)) then
pocket:removeItem(item, number)
end
end
function LootManager:getItemData(type, item)
return itemutils.getItemData(type, item)
end

View file

@ -26,6 +26,18 @@ function Pocket:addItem(item, number)
end
end
function Pocket:removeItem(item, number)
for i,itemData in ipairs(self.list) do
if (itemData.name == item) then
if (itemData.number > number) then
itemData.number = itemData.number - number
else
table.remove(self.list, i)
end
end
end
end
function Pocket:getItem(name)
for i, itemData in ipairs(self.list) do
if (itemData.name == name) then