inv diagnostics + repacked tables

This commit is contained in:
MrNewb committed 2025-05-09 02:00:02 -04:00
1 parent c0662e1069
commit 485c2d3460
20 files changed
+69 -36

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
Inventory = Inventory or {}
---This will fallback to framework add item functions when an inventory does not have the specifiec function.
+1
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
Inventory = Inventory or {}
---This will fallback to framework add item functions when an inventory does not have the specifiec function.
+3 -2
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('codem-inventory') ~= 'started' then return end
Inventory = Inventory or {}
@@ -8,8 +9,9 @@ local codem = exports['codem-inventory']
---@return table
Inventory.GetItemInfo = function(item)
local itemData = codem:GetItemList(item)
if not itemData then return {} end
local image = itemData.image and Inventory.GetImagePath(itemData.image) or Inventory.GetImagePath(item)
local repackedTable = {
return {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
@@ -17,7 +19,6 @@ Inventory.GetItemInfo = function(item)
description = itemData.description or "none",
image = image,
}
return repackedTable or {}
end
---comment
+3 -2
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('codem-inventory') ~= 'started' then return end
Inventory = Inventory or {}
@@ -6,7 +7,8 @@ local codem = exports['codem-inventory']
Inventory.GetItemInfo = function(item)
local itemData = codem:GetItemList(item)
local repackedTable = {
if not itemData then return {} end
return {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
@@ -14,7 +16,6 @@ Inventory.GetItemInfo = function(item)
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable or {}
end
Inventory.AddItem = function(src, item, count, slot, metadata)
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('core_inventory') ~= 'started' then return end
Inventory = Inventory or {}
+1 -1
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('core_inventory') ~= 'started' then return end
Inventory = Inventory or {}
@@ -76,7 +77,6 @@ Inventory.GetItemBySlot = function(src, slot)
local inv = Inventory.GetPlayerInventory(src)
if not inv then return {} end
for _, v in pairs(inv) do
print(v.slot, slot)
if v.slot == slot then
return {
name = v.name,
+2 -2
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('jpr-inventory') ~= 'started' then return end
local jpr = exports['jpr-inventory']
@@ -29,7 +30,7 @@ end
Inventory.GetItemInfo = function(item)
local itemData = Framework.Shared.Items[item]
if not itemData then return {} end
local repackedTable = {
return {
name = itemData.name,
label = itemData.label,
stack = itemData.unique,
@@ -37,5 +38,4 @@ Inventory.GetItemInfo = function(item)
description = itemData.description,
image = Inventory.GetImagePath(itemData.name)
}
return repackedTable
end
+11 -1
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('jpr-inventory') ~= 'started' then return end
local jpr = exports['jpr-inventory']
@@ -56,7 +57,16 @@ end
Inventory.GetItemBySlot = function(src, slot)
local slotData = jpr:GetItemBySlot(src, slot)
if not slotData then return {} end
return { name = slotData.name, label = slotData.label, weight = slotData.weight, slot = slot, count = slotData.amount, metadata = slotData.info, stack = slotData.unique, description = slotData.description }
return {
name = slotData.name,
label = slotData.label,
weight = slotData.weight,
slot = slot,
count = slotData.amount,
metadata = slotData.info,
stack = slotData.unique,
description = slotData.description
}
end
---comment
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('origen_inventory') ~= 'started' then return end
Inventory = Inventory or {}
@@ -9,7 +10,8 @@ local origin = exports.origen_inventory
---@return table
Inventory.GetItemInfo = function(item)
local itemData = origin:Items(item)
local repackedTable = {
if not itemData then return {} end
return {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
@@ -17,7 +19,6 @@ Inventory.GetItemInfo = function(item)
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable or {}
end
---comment
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('origen_inventory') ~= 'started' then return end
Inventory = Inventory or {}
@@ -25,7 +26,8 @@ end
Inventory.GetItemInfo = function(item)
local itemData = origen_inventory:Items(item)
local repackedTable = {
if not itemData then return {} end
return {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
@@ -33,7 +35,6 @@ Inventory.GetItemInfo = function(item)
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable or {}
end
Inventory.GetItemCount = function(src, item, metadata)
+2 -2
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('ox_inventory') ~= 'started' then return end
local ox_inventory = exports.ox_inventory
@@ -9,7 +10,7 @@ Inventory = Inventory or {}
Inventory.GetItemInfo = function(item)
local itemData = ox_inventory:Items(item)
if not itemData then return {} end
local repackedTable = {
return {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.stack or "true",
@@ -17,7 +18,6 @@ Inventory.GetItemInfo = function(item)
description = itemData.description or "none",
image = (itemData.client and itemData.client.image) or Inventory.GetImagePath(item),
}
return repackedTable
end
---comment
+3 -6
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('ox_inventory') ~= 'started' then return end
local ox_inventory = exports.ox_inventory
@@ -19,18 +20,14 @@ end
Inventory.GetItemInfo = function(item)
local itemData = ox_inventory:Items(item)
if not itemData then return {} end
local repackedTable = {
return {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.stack or "true",
weight = itemData.weight or "0",
description = itemData.description or "none",
image = string.format("nui://ox_inventory/web/images/%s", itemData.client
and itemData.client.image
or string.format("%s.png", item)
),
image = string.format("nui://ox_inventory/web/images/%s", itemData.client and itemData.client.image or string.format("%s.png", item)),
}
return repackedTable
end
-- string.format("nui://ox_inventory/web/images/%s.png", item)
+2 -2
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('ps-inventory') ~= 'started' then return end
local ps = exports['ps-inventory']
@@ -31,7 +32,7 @@ end
Inventory.GetItemInfo = function(item)
local itemData = Framework.Shared.Items[item]
if not itemData then return {} end
local repackedTable = {
return {
name = itemData.name,
label = itemData.label,
stack = itemData.unique,
@@ -39,5 +40,4 @@ Inventory.GetItemInfo = function(item)
description = itemData.description,
image = Inventory.GetImagePath(itemData.name)
}
return repackedTable
end
+11 -1
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('ps-inventory') ~= 'started' then return end
local sloth = exports['ps-inventory']
@@ -57,7 +58,16 @@ end
Inventory.GetItemBySlot = function(src, slot)
local slotData = sloth:GetItemBySlot(src, slot)
if not slotData then return {} end
return {name = slotData.name, label = slotData.name, weight = slotData.weight, slot = slot, count = slotData.amount, metadata = slotData.info, stack = slotData.unique, description = slotData.description}
return {
name = slotData.name,
label = slotData.name,
weight = slotData.weight,
slot = slot,
count = slotData.amount,
metadata = slotData.info,
stack = slotData.unique,
description = slotData.description
}
end
---comment
+2 -2
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('qb-inventory') ~= 'started' then return end
local qb = exports['qb-inventory']
@@ -30,7 +31,7 @@ end
Inventory.GetItemInfo = function(item)
local itemData = Framework.Shared.Items[item]
if not itemData then return {} end
local repackedTable = {
return {
name = itemData.name,
label = itemData.label,
stack = itemData.unique,
@@ -38,6 +39,5 @@ Inventory.GetItemInfo = function(item)
description = itemData.description,
image = Inventory.GetImagePath(itemData.image or itemData.name)
}
return repackedTable
end
+2 -2
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('qb-inventory') ~= 'started' then return end
local qbInventory = exports['qb-inventory']
@@ -43,7 +44,7 @@ end
Inventory.GetItemInfo = function(item)
local itemData = Framework.Shared.Items[item]
if not itemData then return {} end
local repackedTable = {
return {
name = itemData.name,
label = itemData.label,
stack = itemData.unique,
@@ -51,7 +52,6 @@ Inventory.GetItemInfo = function(item)
description = itemData.description,
image = Inventory.GetImagePath(itemData.image or itemData.name)
}
return repackedTable
end
---comment
+2 -2
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('qs-inventory') ~= 'started' then return end
local quasar = exports["qs-inventory"]
Inventory = Inventory or {}
@@ -17,7 +18,7 @@ Inventory.GetItemInfo = function(item)
if not itemsData then return {} end
local itemData = itemsData[item]
if not itemData then return {} end
local repackedTable = {
return {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
@@ -25,7 +26,6 @@ Inventory.GetItemInfo = function(item)
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable
end
---comment
+2 -2
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('qs-inventory') ~= 'started' then return end
local quasar = exports['qs-inventory']
@@ -131,7 +132,7 @@ Inventory.GetItemInfo = function(item)
if not itemsData then return {} end
local itemData = itemsData[item]
if not itemData then return {} end
local repackedTable = {
return {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
@@ -139,7 +140,6 @@ Inventory.GetItemInfo = function(item)
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable
end
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('tgiann-inventory') ~= 'started' then return end
local tgiann = exports["tgiann-inventory"]
@@ -14,7 +15,7 @@ end
Inventory.GetItemInfo = function(item)
local itemData = tgiann:GetItemList()
if not itemData[item] then return {} end
local repackedTable = {
return {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
@@ -22,7 +23,6 @@ Inventory.GetItemInfo = function(item)
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable
end
---comment
+12 -3
View File
@@ -1,3 +1,4 @@
---@diagnostic disable: duplicate-set-field
if GetResourceState('tgiann-inventory') ~= 'started' then return end
local tgiann = exports["tgiann-inventory"]
@@ -100,7 +101,16 @@ 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}
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
---This will return a table of the item data including the image (very useful for menus etc)
@@ -109,7 +119,7 @@ end
Inventory.GetItemInfo = function(item)
local itemData = tgiann:GetItemList()
if not itemData[item] then return {} end
local repackedTable = {
return {
name = itemData.name or "Missing Name",
label = itemData.label or "Missing Label",
stack = itemData.unique or "false",
@@ -117,7 +127,6 @@ Inventory.GetItemInfo = function(item)
description = itemData.description or "none",
image = itemData.image or Inventory.GetImagePath(item),
}
return repackedTable
end
---This will update the item metadata for an item with the provided slot and metadata, its best to get the item first