summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2014-07-15 00:38:01 +0200
committerWuzzy <almikes@aol.com>2014-07-15 00:38:01 +0200
commitc400ac1ed9fd6d5dfa9f498a093270de03e01c9e (patch)
tree8911261dc3c890116385e5f792c235dfde493d64 /init.lua
parent7a411df76ea2c74b3f5e3d8eea257777ae7edb5d (diff)
Add cancel_on_death parameter for effect types.
This optional parameter controls wheather the effect shall be cancelled when the player dies. By default, this is true.
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index fe7eb32..90fb347 100644
--- a/init.lua
+++ b/init.lua
@@ -47,7 +47,7 @@ function playereffects.next_effect_id()
end
--[=[ API functions ]=]
-function playereffects.register_effect_type(effect_type_id, description, icon, groups, apply, cancel, hidden)
+function playereffects.register_effect_type(effect_type_id, description, icon, groups, apply, cancel, hidden, cancel_on_death)
effect_type = {}
effect_type.description = description
effect_type.apply = apply
@@ -63,6 +63,12 @@ function playereffects.register_effect_type(effect_type_id, description, icon, g
else
effect_type.hidden = false
end
+ if cancel_on_death ~= nil then
+ effect_type.cancel_on_death = cancel_on_death
+ else
+ effect_type.cancel_on_death = true
+ end
+
playereffects.effect_types[effect_type_id] = effect_type
minetest.log("action", "[playereffects] Effect type "..effect_type_id.." registered!")
end
@@ -257,7 +263,9 @@ end
minetest.register_on_dieplayer(function(player)
local effects = playereffects.get_player_effects(player:get_player_name())
for e=1,#effects do
- playereffects.cancel_effect(effects[e].effect_id)
+ if(playereffects.effect_types[effects[e].effect_type_id].cancel_on_death == true) then
+ playereffects.cancel_effect(effects[e].effect_id)
+ end
end
end)