diff options
Diffstat (limited to 'tutorials/tut040_items.md')
| -rw-r--r-- | tutorials/tut040_items.md | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tutorials/tut040_items.md b/tutorials/tut040_items.md new file mode 100644 index 0000000..954f9cd --- /dev/null +++ b/tutorials/tut040_items.md @@ -0,0 +1,25 @@ +# Tut 0x040 + +## Items + +Items are a lot like inventories, but much simpler. Let's make one! + + local item_registry = nrequire("item.lua") + local item = {} + + item.Name = "My first item" + + function item:Serialize() + return "" + end + + --Recall that we said in @{tut030_inventories.md} we said items that work in our inventory will have a .weight field + item.weight = 20 + + function item:DeSerialize() + return table.Copy(self) + end + + item_registry.RegisterItem(item) + +That's it! We're Done! Note you can use the same trick in DeSerialize() as in @{tut031_metatables.md}. You can now load in to the game and use `artery_printitems` to show a list of items, and see "My first item" as one of them! |
