export GetInventoryItems standard, add export GetItemBySlot
This commit is contained in:
1 parent
1d23d256c0
commit
0c90d659a0
14 files changed
+210
-41
No files matched your search
@@ -1,16 +1,16 @@
|
||||
if GetResourceState('tgiann-inventory') ~= 'started' then return end
|
||||
|
||||
local tgiann = exports["tgiann-inventory"]
|
||||
|
||||
Inventory = Inventory or {}
|
||||
|
||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||
if not tgiann:CanCarryItem(src, item, count) then return false end
|
||||
local action = tgiann:AddItem(src, item, count, metadata)
|
||||
return (action.itemAddRemoveLog == 'added')
|
||||
return tgiann:AddItem(src, item, count, slot, metadata, false)
|
||||
end
|
||||
|
||||
Inventory.RemoveItem = function(src, item, count, slot, metadata)
|
||||
return tgiann:RemoveItem(src, item, count, nil, metadata)
|
||||
return tgiann:RemoveItem(src, item, count, slot, metadata)
|
||||
end
|
||||
|
||||
Inventory.GetItem = function(src, item, metadata)
|
||||
@@ -26,7 +26,14 @@ Inventory.GetItemCount = function(src, item, metadata)
|
||||
end
|
||||
|
||||
Inventory.GetInventoryItems = function(src)
|
||||
return tgiann:GetPlayerItems(src)
|
||||
local inventory = tgiann:GetPlayerItems(src)
|
||||
local items = {}
|
||||
for _, v in pairs(inventory) do
|
||||
if tonumber(_) then
|
||||
table.insert(items, {name = v.name, label = v.name, weight = 0, description = v.description, slot = v.slot, count = v.amount, metadata = v.info})
|
||||
end
|
||||
end
|
||||
return items
|
||||
end
|
||||
|
||||
Inventory.CanCarryItem = function(src, item, count)
|
||||
@@ -37,6 +44,12 @@ Inventory.RegisterStash = function(id, label, slots, weight, owner)
|
||||
return tgiann:CreateCustomStashWithItem(id, {})
|
||||
end
|
||||
|
||||
Inventory.GetItemBySlot = function(src, slot)
|
||||
local item = tgiann:GetItemBySlot(src, slot)
|
||||
if not item then return {} end
|
||||
return {name = item.name, label = item.label, weight = item.weight, slot = slot, count = item.amount, metadata = item.info, stack = item.unique or false, description = item.description}
|
||||
end
|
||||
|
||||
Inventory.GetItemInfo = function(item)
|
||||
local itemData = tgiann:GetItemList()
|
||||
if not itemData[item] then return {} end
|
||||
|
||||
Reference in new issue
Block a user