diff options
author | Wuzzy <almikes@aol.com> | 2014-07-19 00:59:19 +0200 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2014-07-19 00:59:19 +0200 |
commit | 87699ab3b2119e5329a7bc62441536a6a51cd80a (patch) | |
tree | ed42a2e27744118595c7cbc54833391f2d958586 /examples.lua | |
parent | aa5f78ef9552309269cd7b916172e81a23bf87d0 (diff) |
New effect type: repeating effects
Diffstat (limited to 'examples.lua')
-rw-r--r-- | examples.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/examples.lua b/examples.lua index 0a510d8..93c4980 100644 --- a/examples.lua +++ b/examples.lua @@ -102,6 +102,23 @@ playereffects.register_effect_type("fly", "Fly mode available", "playereffects_e false -- do NOT cancel the effect on death ) +-- Repeating effect type: Adds 1 HP per second +playereffects.register_effect_type("regen", "Regeneration", "heart.png", {"health"}, + function(player) + player:set_hp(player:get_hp()+1) + end, + nil, nil, nil, 1 +) + +-- Repeating effect type: Adds 1 HP per 3 seconds +playereffects.register_effect_type("slowregen", "Slow Regeneration", "heart.png", {"health"}, + function(player) + player:set_hp(player:get_hp()+1) + end, + nil, nil, nil, 15 +) + + -- Dummy effect for the stree test playereffects.register_effect_type("stress", "Stress Test Effect", nil, {}, function(player) @@ -111,6 +128,7 @@ playereffects.register_effect_type("stress", "Stress Test Effect", nil, {}, ) + ------ Chat commands for the example effects ------ -- Null effect (never succeeds) minetest.register_chatcommand("null", { @@ -179,6 +197,26 @@ minetest.register_chatcommand("fly", { end, }) +minetest.register_chatcommand("regen", { + params = "", + description = "Gives you 1 half heart per second 10 times, healing you by 5 hearts in total.", + privs = {}, + func = function(name, param) + local ret = playereffects.apply_effect_type("regen", 10, minetest.get_player_by_name(name)) + notify(name, ret) + end, +}) + +minetest.register_chatcommand("slowregen", { + params = "", + description = "Gives you 1 half heart every 3 seconds 10 times, healing you by 5 hearts in total.", + privs = {}, + func = function(name, param) + local ret = playereffects.apply_effect_type("slowregen", 10, minetest.get_player_by_name(name)) + notify(name, ret) + end, +}) + --[[ Cancel all active effects ]] |