diff options
author | Wuzzy <almikes@aol.com> | 2014-07-14 17:28:51 +0200 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2014-07-14 17:28:51 +0200 |
commit | 21f053270f0015438e28b347a87ba9a151c59aff (patch) | |
tree | 3dd7f777d06c6c3c4ef08a6c4485825c26ac84fb /init.lua | |
parent | a91e4c79ce2db34f8bfcfd0717b02b54e10b9363 (diff) |
Add effect metadata
Effect metadata is a means to store additional user-defined data for the effect,
which can be reused when the cancel function of the effect is called.
This commit also adds a new example (blind) to demonstrate usage of that.
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -105,6 +105,8 @@ function playereffects.apply_effect_type(effect_type_id, duration, player) hudids = {text_id=nil, icon_id=nil} end + local metadata = playereffects.effect_types[effect_type_id].apply(player) + local effect = { playername = playername, effect_id = effect_id, @@ -113,11 +115,11 @@ function playereffects.apply_effect_type(effect_type_id, duration, player) time_left = duration, hudids = hudids, hudpos = free_hudpos, - } + metadata = metadata, + } playereffects.effects[effect_id] = effect - - playereffects.effect_types[effect_type_id].apply(player) + minetest.log("action", "[playereffects] Effect type "..effect_type_id.." applied to player "..playername.."!") minetest.after(duration, function(effect_id) playereffects.cancel_effect(effect_id) end, effect_id) end @@ -202,6 +204,7 @@ function playereffects.save_to_file() time_left = new_duration, start_time = effect.start_time, playername = effect.playername, + metadata = effect.metadata } if(inactive_effects[effect.playername] == nil) then inactive_effects[effect.playername] = {} |