aboutsummaryrefslogtreecommitdiff
path: root/tutorials/tut050_entities.md
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2018-02-28 09:41:23 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2018-02-28 09:41:23 -0500
commit5fd5f2b3d1c77c3b85355c452ffc7e1fe2e12162 (patch)
treeba03a7c2975e2c5c88732cc28be90365e6cd41aa /tutorials/tut050_entities.md
parenta77ee4ce201de757ce4c5958d9e499a65b2cf416 (diff)
downloadartery-5fd5f2b3d1c77c3b85355c452ffc7e1fe2e12162.tar.gz
artery-5fd5f2b3d1c77c3b85355c452ffc7e1fe2e12162.tar.bz2
artery-5fd5f2b3d1c77c3b85355c452ffc7e1fe2e12162.zip
Fixed some types, worked on 0x050
Fixed typos in a bunch of tutorials, did a little more work on 0x050 - Entities
Diffstat (limited to 'tutorials/tut050_entities.md')
-rw-r--r--tutorials/tut050_entities.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/tutorials/tut050_entities.md b/tutorials/tut050_entities.md
index 1e1e837..e443cae 100644
--- a/tutorials/tut050_entities.md
+++ b/tutorials/tut050_entities.md
@@ -27,3 +27,28 @@ garrysmod/addons/artery\_rougelite/data/global/entity\_fountain.txt
end
scripted_ents.Register(ENT, "artery_fountain")
+
+garrysmod/addons/artery\_rogelite/data/global/entity\_alter.txt
+
+ local ENT = scripted_ents.Get("prop_dynamic")
+
+ function ENT:Initalize()
+ 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
+
+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.