aboutsummaryrefslogtreecommitdiff
path: root/gamemode/core/inventory/item.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/core/inventory/item.lua')
-rw-r--r--gamemode/core/inventory/item.lua14
1 files changed, 9 insertions, 5 deletions
diff --git a/gamemode/core/inventory/item.lua b/gamemode/core/inventory/item.lua
index 9a6a293..79f9ad5 100644
--- a/gamemode/core/inventory/item.lua
+++ b/gamemode/core/inventory/item.lua
@@ -1,6 +1,8 @@
---The main module to use when createing new items.
-- Registers items that will work with the inventory system
--@shared item.lua
+--@alias itm
+
--[[
An itemsystem
public functions:
@@ -18,7 +20,6 @@
item:DeSerialize(string_data) ::nil
Recreate an item. If this item has any instance specific data, it should return a table.Copy(self) with the appropriate fields set.
The above must be defined for every item
- Items may also have methods from one or more interfaces registered with RegisterInterface
]]
local log = nrequire("log.lua")
@@ -31,8 +32,7 @@ local items = items or {} --Master table of all item prototypes
---Registers an item.
-- Registers an item that can be gotten later. It usually dosn't make sense for only parts of the level to have an item (the player probably can travel between all the parts of your world with the item in their inventory), therefore you should make sure items are loaded globally.
---@see itemtbl
---@tparam table tbl The table to register for the item prototype
+--@tparam itemtbl tbl The table to register for the item prototype
function itm.RegisterItem(tbl)
for k,v in pairs(required_fields) do
assert(tbl[v] ~= nil, string.format("Attempted to register item without field %q",v))
@@ -50,7 +50,7 @@ end
---Gets an instance of an item.
-- Gets an instanced copy of an item registered with RegisterItem()
--@tparam string name The name of the item
---@treturn itemtbl item The item
+--@treturn itemtbl The item
function itm.GetItemByName(name)
assert(type(name) == "string",string.format("Attempted to get an item by name with a %s.",type(name)))
assert(items[name] ~= nil,string.format("Attempted to get item with invalid name %q Valid item names are:\n\t%s",name,table.concat(table.GetKeys(items),"\n\t")))
@@ -67,6 +67,7 @@ end
-- Just gets the item, then calls DeSerialize(), returning whatever deserialize returned
--@tparam string name The name of the item
--@tparam string data The data to instantiate the item with
+--@treturn itemtbl The item that was deserialized
function itm.GetItemFromData(name,data)
assert(items[name] ~= nil,string.format("Attempted to get item with invalid name %q",name))
return items[name]:DeSerialize(data)
@@ -101,6 +102,9 @@ end
hook.Call("artery_include_items")
-concommand.Add("art_printitems",printitems)
+---Prints a list of all items the client/server knows about
+--@concommand artery_printitems
+--@usage artery_printitems
+concommand.Add("artery_printitems",printitems)
return itm