From 7787bd2c32261ffbc93ff05b1aaef8723083892b Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Tue, 9 Jan 2018 19:00:19 -0500 Subject: More work on tutorials started on entities tutorial, finished not enough items, and made a minor grammer correction to setup. --- tutorials/tut050_entities.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tutorials/tut050_entities.md (limited to 'tutorials/tut050_entities.md') 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") -- cgit v1.2.3-70-g09d2