Mod
Persistent Effects
An API for creating persistent effects for any object. eg. damage a player or entity over time. (like poison)
A minetest api that allows for easy creation of persistent effects. for example: changing a players health over time with a set interval (eg; poison or healing)
how to use:
Simply use the one function
persistent_api.add_persistent_effect(def)
like this
persistent_api.add_persistent_effect({
name = string,
-- effect identifier. Will be overwritten if another effect is added to the same object with the same identifier.
object = ObjectRef,
-- ObjectRef which is referenced and attached to the effect.
duration = float,
-- amount of time until the effect is removed.
effect = function(ObjectRef)
-- function that is run every time the effect is called.
persistence = float,
-- how often (in seconds) the effect function is run.
})
for example
local player = minetest.get_player_by_name("JohnSmith")
persistent_api.add_persistent_effect({
name = "damage_player", -- identifier
object = player, -- affected object
duration = 10, -- this effect will last 10 seconds
effect = function(player)
player:set_hp(player:get_hp()-1) -- damage the player one half heart
end,
persistence = 0.1, -- every 0.1 seconds for 10 seconds the previous function will be run.
}) Links
- Source: https://github.com/epCode/persistent_api.git
- Issues: https://github.com/epCode/persistent_api/issues
- Original ContentDB page: content.luanti.org/packages/epCode/persistent_effects/
License
LGPL-3.0-only
Development state
MAINTENANCE_ONLY
| Version | Date | Min engine | Size | Download |
|---|---|---|---|---|
| 1.0.0 | 2023-08-10 03:51:09 | 9.8 KB | Download |