aboutsummaryrefslogtreecommitdiff
path: root/tutorials/tut050_entities.md
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 /tutorials/tut050_entities.md
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.
Diffstat (limited to 'tutorials/tut050_entities.md')
-rw-r--r--tutorials/tut050_entities.md29
1 files changed, 29 insertions, 0 deletions
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")