feat: add item removal functions
This commit is contained in:
parent
3353ae7d37
commit
7b375bfed2
2 changed files with 19 additions and 0 deletions
|
@ -51,6 +51,13 @@ function LootManager:addItem(type, item, number)
|
||||||
end
|
end
|
||||||
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)
|
function LootManager:getItemData(type, item)
|
||||||
return itemutils.getItemData(type, item)
|
return itemutils.getItemData(type, item)
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,6 +26,18 @@ function Pocket:addItem(item, number)
|
||||||
end
|
end
|
||||||
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)
|
function Pocket:getItem(name)
|
||||||
for i, itemData in ipairs(self.list) do
|
for i, itemData in ipairs(self.list) do
|
||||||
if (itemData.name == name) then
|
if (itemData.name == name) then
|
||||||
|
|
Loading…
Reference in a new issue