aboutsummaryrefslogtreecommitdiff
path: root/tutorials/tut050_entities.md
diff options
context:
space:
mode:
Diffstat (limited to 'tutorials/tut050_entities.md')
-rw-r--r--tutorials/tut050_entities.md25
1 files changed, 5 insertions, 20 deletions
diff --git a/tutorials/tut050_entities.md b/tutorials/tut050_entities.md
index f223228..d4d4200 100644
--- a/tutorials/tut050_entities.md
+++ b/tutorials/tut050_entities.md
@@ -2,7 +2,7 @@
## 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.
+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 placing 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:
@@ -26,7 +26,7 @@ garrysmod/addons/artery\_rougelite/data/global/entity\_fountain.txt
print("Mmm... Refreshing!")
end
- scripted_ents.Register(ENT, "artery_fountain")
+ scripted_ents.Register(ENT, "artery_my_fountain")
### Alter
@@ -54,9 +54,9 @@ garrysmod/addons/artery\_rogelite/data/global/entity\_alter.txt
end
end
- scripted_ents.Register(ENT, "artery_fountain")
+ scripted_ents.Register(ENT, "artery_my_alter")
-It may have been tempting here to just set the item's .attribute in our iscursed() function, since it will be the first place we detect a cursed item. **HOWEVER!** There are a lot of places in Artery that this kind of thing can BREAK other addons. Generally speaking, try not to modify items while they're in an inventory. Remove them, modify them, then add them back.
+It may have been tempting here to just set the item's .attribute in our iscursed() function, since it will be the first place we detect a cursed item. **HOWEVER!** There are a lot of places in Artery that this kind of thing can BREAK other addons. Generally speaking, try not to modify items while they're in an inventory. Remove them, modify them, then add them back. This allows the server to update the client's information, in case the client needs to show something different on screen depending on an item's attributes.
### Chest
@@ -70,19 +70,4 @@ This one is pretty easy, it's really only here to show you how to extend the ent
self:SetModel("models/props_junk/wood_crate002a.mdl")
end
- function ENT:Use(ply)
- --Get all the items the player has that are cursed
- local iscursed = function(item)
- if item.attribute == -1 then -- Item is cursed
- return true
- end
- end
- local to_uncurse_pos = ply:HasItem(iscursed)
- while(to_uncurse_pos) do --Will be nil if we don't have any cursed items
- local item = ply:RemoveItem(to_uncurse_pos)
- item.attribute = nil
- ply:GiveItem(item)
- end
- end
-
- scripted_ents.Register(ENT, "artery_fountain")
+ scripted_ents.Register(ENT, "artery_my_chest")