SaKeL wrote:How do i check if the effect was already applied to the player so it will not get applied again ?
Im trying to get my head around it and work with the sets
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
monoidal_effects.get_player_effects(user:get_player_name()):effects()
but nothing is working (yet)... just trying to find the simple way how to apply an effect to the player only if it's not already active (so no multiple times)
Your help would be appreciated.
get_player_effects returns a set (i.e. a table with { foo = true, bar = true} if foo and bar are in the set }, not an effectset. Effectsets are not part of the public API, the documentation is just there for use while developing the mod.
Unfortunately right now there is no simple way to determine if an effect is of a particular type. I'm not sure if I want to make more additions to monoidal_effects, since I am thinking of merging functionality into playereffects.
It might be possible that your use-case is covered by first canceling effects of that effect type, then reapplying them. That could be done like
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
monoidal_effects.cancel_effect_type(eff_type, player_name)
monoidal_effects.apply_effect(eff_type, dur, player_name)
Every time a mod API is left undocumented, a koala dies.