diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2019-05-04 15:52:00 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2019-05-04 15:52:00 -0400 |
| commit | faa8312074e6ea8a96efd70d6188ef592f81e579 (patch) | |
| tree | 5b2d47dae86a2f5fd96c379a20163177b44e20ea /tutorials/tut031_metatables.md | |
| parent | 984401ce1f84581786f9e3241caf96bda718940b (diff) | |
| download | artery-faa8312074e6ea8a96efd70d6188ef592f81e579.tar.gz artery-faa8312074e6ea8a96efd70d6188ef592f81e579.tar.bz2 artery-faa8312074e6ea8a96efd70d6188ef592f81e579.zip | |
Updated tutorials
Various fixes and updates for the tutorials
Diffstat (limited to 'tutorials/tut031_metatables.md')
| -rw-r--r-- | tutorials/tut031_metatables.md | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tutorials/tut031_metatables.md b/tutorials/tut031_metatables.md index a397cc9..62eea66 100644 --- a/tutorials/tut031_metatables.md +++ b/tutorials/tut031_metatables.md @@ -2,7 +2,9 @@ ## Metatables -In the last tutorial we saw how to make a simple inventory, but we used a function from Gmod's library that was a bit silly. When we made a copy of our inventory, we used table.Copy() to return a copy seperate to the version in the registry. There's nothing wrong with this, but if you have a lot of fields, and default tables in your inventory, this can get quite costly. There's a simple alternative, lua metatables. +***TODO:*** Consider scraping this tutorial, it no longer is correct or relevant to inventories (Maybe move it under the item's tutorials?) + +In the last tutorial we saw how to make a simple inventory, but we used a function from Gmod's library that was a bit silly. When we made a copy of our inventory, we used table.Copy() to return a copy separate to the version in the registry. There's nothing wrong with this, but if you have a lot of fields, and default tables in your inventory, this can get quite costly. There's a simple alternative, Lua Metatables. [Programming in Lua](https://www.lua.org/pil/13.html) does a much better job at explaining metatables than I ever could, so take a look at how they use it. We're not going to use all the features they discuss, just 1: the \_\_index method, to replace the DeSerialize() function from @{tut030_inventories.md}. |
