aboutsummaryrefslogtreecommitdiff
path: root/tutorials/tut041_not_enough_items.md
diff options
context:
space:
mode:
Diffstat (limited to 'tutorials/tut041_not_enough_items.md')
-rw-r--r--tutorials/tut041_not_enough_items.md47
1 files changed, 28 insertions, 19 deletions
diff --git a/tutorials/tut041_not_enough_items.md b/tutorials/tut041_not_enough_items.md
index 895e1fd..7b8a65f 100644
--- a/tutorials/tut041_not_enough_items.md
+++ b/tutorials/tut041_not_enough_items.md
@@ -6,22 +6,31 @@ It frequently happens that you want many items with only slight variations. In t
First, we need to find all the npc's the game knows about, then create an item for each one.
-garrysmod/addons/artery_routelite/data/artery/global/npc_corpses.lua
-```
-local base = {}
-
-base.Name = "Meat base"
-
-base.weight = 10
-
-function base:Serialize()
- return ""
-end
-
-function base:DeSerialize()
- return table.Copy(self)
-end
-
-
-
-```
+garrysmod/addons/artery\_rougelite/data/artery/global/npc\_corpses.lua
+
+ local reg = nrequire("core/inventory/item.lua")
+ local base = {}
+
+ base.Name = "Meat base"
+
+ base.weight = 10
+
+ function base:Serialize()
+ return ""
+ end
+
+ function base:DeSerialize()
+ return table.Copy(self)
+ end
+
+ local allnpcs = list.Get("NPC")
+ for k,v in pairs(allnpcs) do
+ if k.Name then
+ local item = table.Copy(base) --Make a copy of the above "base" table
+ item.Name = k.Name .. " Meat" --Give it a name of "<something> Meat"
+ reg.RegisterItem(item) --Add it to the game
+ end
+ end
+
+That's it! Restart the gamemode, and use `artery_printitems` to see the items in console!
+