From 25e4d04a331a6a0b9d897d4f721757730771ff97 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sat, 18 Nov 2017 16:00:29 -0500 Subject: More documentation * Documented the item table * Documented the inventory table * Started writing tutorials --- gamemode/itemsystem/exampleitem.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'gamemode/itemsystem/exampleitem.lua') diff --git a/gamemode/itemsystem/exampleitem.lua b/gamemode/itemsystem/exampleitem.lua index 269e2d6..196db20 100644 --- a/gamemode/itemsystem/exampleitem.lua +++ b/gamemode/itemsystem/exampleitem.lua @@ -1,3 +1,7 @@ +---An example item. +-- An item you can create a copy of as a starting point. This is the minimum needed for an item. Different inventories usually also require different fields and functions. +--@classmod itemtbl + --[[ An example item ]] @@ -6,19 +10,27 @@ local item = {} --Make sure we identify ourselves as a prayer item.isprayer = true ---Required, a name, all item names must be unique +---A name. +-- All items must have a .Name, which gives a string, an item should give the same string each time. You can generate an item's name from it's data by leaving this blank, and giving the item a metatable with a __index method that does the right thing item.Name = "Test item" --Optional, a tooltip to display when hovered over item.Tooltip = "An example item. Copy this file\nand edit it to make your own items!" ---Required Returns the data needed to rebuild this item, should only contain the minimum data nessessary since this gets sent over the network +---Create a string representation of this item. +-- Returns the data needed to rebuild this item, should only contain the minimum data nessessary since this gets sent over the network. +--@tparam itemtbl self The item we need to serialize +--@treturn string The string representation of this item (can be length 0) item.Serialize = function(self) print("Trying to serailize!") return "" end ---Required, Rebuilds the item from data created in Serialize, if the item is different from the "main" copy of the item, it should retun a tabl.Copy(self), with the appropriate fields set. +---Recreates an item from data. +-- Rebuilds the item from data created in Serialize, if the item is different from the "main" copy of the item, it should retun a tabl.Copy(self), with the appropriate fields set. +--@tparam itemtbl self The prototype table we want to deserialize from +--@tparam string string The data given by a Serailize() method +--@treturn itemtbl The fully deserialized item item.DeSerialize = function(self,string) print("Trying to deserialize!") return self -- cgit v1.2.3-70-g09d2