diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2017-11-26 21:07:54 -0500 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2017-11-26 21:07:54 -0500 |
| commit | 83af51534bf16bf048aea1cd3b74a0308ed9dd71 (patch) | |
| tree | ff82f3e6dd841633b1355b73181bcae607ee1138 /tutorials/tut040_items.md | |
| parent | 25e4d04a331a6a0b9d897d4f721757730771ff97 (diff) | |
| download | artery-83af51534bf16bf048aea1cd3b74a0308ed9dd71.tar.gz artery-83af51534bf16bf048aea1cd3b74a0308ed9dd71.tar.bz2 artery-83af51534bf16bf048aea1cd3b74a0308ed9dd71.zip | |
Started work on writing tutorials
Wrote tutorials for
* Setup
* Addon structure
* Inventories
* Items
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! |
