1
0
mirror of https://repo.or.cz/minetest_playereffects.git synced 2025-06-30 23:30:41 +02:00

New effect type: repeating effects

This commit is contained in:
Wuzzy
2014-07-19 00:59:19 +02:00
parent aa5f78ef95
commit 87699ab3b2
3 changed files with 129 additions and 23 deletions

View File

@ -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
]]