aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2018-01-09 19:00:19 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2018-01-09 19:00:19 -0500
commit7787bd2c32261ffbc93ff05b1aaef8723083892b (patch)
tree9c487f3e70d1415068b27a4c182aa5c76eb4c3e5
parente2dc5bf1fec1e634a60801aca3acf41422e0c880 (diff)
downloadartery-7787bd2c32261ffbc93ff05b1aaef8723083892b.tar.gz
artery-7787bd2c32261ffbc93ff05b1aaef8723083892b.tar.bz2
artery-7787bd2c32261ffbc93ff05b1aaef8723083892b.zip
More work on tutorials
started on entities tutorial, finished not enough items, and made a minor grammer correction to setup.
-rw-r--r--config.ld1
-rw-r--r--tutorials/tut000_setup.md2
-rw-r--r--tutorials/tut041_not_enough_items.md47
-rw-r--r--tutorials/tut050_entities.md29
4 files changed, 59 insertions, 20 deletions
diff --git a/config.ld b/config.ld
index 66884e2..78f49aa 100644
--- a/config.ld
+++ b/config.ld
@@ -52,4 +52,5 @@ readme = {
"tutorials/tut040_items.md",
"tutorials/tut041_not_enough_items.md",
"tutorials/tut042_too_many_items.md",
+ "tutorials/tut050_entities.md",
}
diff --git a/tutorials/tut000_setup.md b/tutorials/tut000_setup.md
index d71455f..05060f2 100644
--- a/tutorials/tut000_setup.md
+++ b/tutorials/tut000_setup.md
@@ -14,7 +14,7 @@ First, you'll need to download the Artery gamemode base. This can be done for up
4. Use the `cd` command to go into your Garry's Mod directory. This is usuallly `C:\Program Files (x86)\Steam\steamapps\common\GarrysMod\garrysmod` (i.e. the command would be `cd "C:\Program Files (x86)\Steam\steamapps\common\GarrysMod\garrysmod"`). You can alternatively go to this location in your file browser, then click the file path at the top, and copy+paste it into your command prompt.
5. Use `cd` again to go into your `gamemodes` directory (i.e `cd gamemodes`)
6. Clone the repository `git clone http://cogarr.net/source/cgit.cgi/artery`
-7. Go back and clone the artery_editor addon (`cd ../addons` then `git clone http://cogarr.net/source/cgit.cgi/artery_editor`)
+7. Go back one level, then into your addons directory and clone the artery_editor addon (`cd ../addons` then `git clone http://cogarr.net/source/cgit.cgi/artery_editor`)
8. Another one `git clone https://cogarr.net/source/cgit.cgi/zones` _*_ Please note that this is a fork of [bobleheadbob's original api](https://github.com/Luabee/Zones), all it does is put the files into an addon format.
9. Finally, be sure you are subscribed to PAC3 on the steam workshop
10. Boot up gmod, select the artery addon, and load into gm_flatgrass to make sure it works! You can skip the next section, and go on to the next tutorial.
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!
+
diff --git a/tutorials/tut050_entities.md b/tutorials/tut050_entities.md
new file mode 100644
index 0000000..1e1e837
--- /dev/null
+++ b/tutorials/tut050_entities.md
@@ -0,0 +1,29 @@
+# Tut 0x050
+
+## Entities
+
+Usually in addons, you have a dedicated folder for entities, however, that's not the only way to create entities. The canonical way to create entities in artery is to use the ![img](http://wiki.garrysmod.com/favicon.ico)[scripted\_ents.Register](http://wiki.garrysmod.com/page/scripted_ents/Register) function. This allows you to register entities after the gamemode has loaded. If your entities don't derive from artery entities, you can still use the usual entity system by placeing a init.lua, cl\_init.lua, and shared.lua in garrysmod/addons/artery\_rougelite/lua/entities.
+
+Let's make some entities that are commonly found in rougelikes. We'll make:
+
+* Fountain - When you go up to and press E on it, you can drink from it.
+* Alter - When you go up to and press E on it, it will remove the "cursed" status that we implemented in @{tut042_too_many_items.md}.
+* Chest - When you go up to it and press E, it will display an inventory you can put items into. We'll use this later on.
+
+### Fountain
+
+This one is easy enough. Just make an entity that spawns with a model, and accepts a "Use" input.
+
+garrysmod/addons/artery\_rougelite/data/global/entity\_fountain.txt
+
+ local ENT = scripted_ents.Get("prop_dynamic")
+
+ function ENT:Initalize()
+ self:SetModel("models/props_c17/fountain_01.mdl")
+ end
+
+ function ENT:Use()
+ print("Mmm... Refreshing!")
+ end
+
+ scripted_ents.Register(ENT, "artery_fountain")