Files

76 lines
2.3 KiB
Lua
Raw Permalink Normal View History

2025-05-09 02:00:02 -04:00
---@diagnostic disable: duplicate-set-field
2025-01-13 14:28:09 -05:00
Inventory = Inventory or {}
---@description This will get the name of the in use resource.
---@return string
Inventory.GetResourceName = function()
return "default"
end
---@description Return the item info in oxs format, {name, label, stack, weight, description, image}
2025-03-03 01:09:24 -05:00
---@param item string
---@return table
2025-01-13 14:28:09 -05:00
Inventory.GetItemInfo = function(item)
return Framework.GetItemInfo(item)
end
---@description Will return boolean if the player has the item.
2025-03-03 01:09:24 -05:00
---@param item string
---@param requiredCount number (optional)
2025-03-03 01:09:24 -05:00
---@return boolean
Inventory.HasItem = function(item, requiredCount)
return Framework.HasItem(item, requiredCount)
2025-02-17 12:34:10 -05:00
end
---@description This will return their count of the item in the players inventory, if not found will return 0.
2025-04-12 02:31:47 -04:00
---@param item string
---@return number
2025-04-07 14:37:22 -04:00
Inventory.GetItemCount = function(item)
return Framework.GetItemCount(item)
end
---@description This will return the players inventory in the format of {name, label, count, slot, metadata}
2025-05-09 03:16:27 -04:00
---@return table
Inventory.GetPlayerInventory = function()
return Framework:GetPlayerInventory()
end
---@description This will get the image path for this item, if not found will return placeholder.
2025-03-03 01:09:24 -05:00
---@param item string
---@return string
2025-01-13 14:28:09 -05:00
Inventory.GetImagePath = function(item)
2025-08-03 15:22:33 -04:00
print("No get image path for this inventory, using default.")
2025-01-13 14:28:09 -05:00
return "https://avatars.githubusercontent.com/u/47620135"
2025-04-16 05:24:03 -05:00
end
---@description This will remove the file extension from the item name if present.
2025-08-03 16:23:19 -04:00
---@param item string
---@return string
2025-04-16 05:24:03 -05:00
Inventory.StripPNG = function(item)
if string.find(item, ".png") then
item = string.gsub(item, ".png", "")
end
return item
end
---@description This will remove the file extension from the item name if present.
2025-08-03 16:23:19 -04:00
---@param item string
---@return string
2025-08-03 15:22:33 -04:00
Inventory.StripWebp = function(item)
if string.find(item, ".webp") then
item = string.gsub(item, ".webp", "")
end
return item
end
---@description This will return the entire items table from the inventory.
---@return table
2025-07-09 17:26:16 -04:00
Inventory.Items = function()
if not Framework.Shared or not Framework.Shared.Items then
local itemList = Framework.ItemList() or { Items = {} }
return itemList.Items
end
2025-07-09 17:26:16 -04:00
return Framework.Shared.Items
end
return Inventory