WeakAuras

WeakAuras

206M Downloads

Maintain trigger state during trigger evaluation

MikeCook9994 opened this issue ยท 5 comments

commented

Is your feature request related to a problem? Please describe.
When writing custom triggers, I commonly want to maintain the existing state. For example, if I find that UNIT_AURA event did not fire for the current player unit, I want to simply return the most recently resolved information for the trigger. Currently I have to manually maintain this information on the aura_env.state is cleared when trigger evaluation starts.

Describe the solution you'd like
Of course I'm not sure what the implications are, but simply not clearing aura_env.state when trigger evaluation starts would be awesome.

Describe alternatives you've considered
Alternatively this could be stored in some other global for a single evaluation loop if that is simply not possible or has significant side effects.

commented

If you save the information in aura_env instead of aura_env.state you won't loose the information when it untrigger.
Also, sorry if i didn't understood exactly what you are trying to achieve, but if you want to continue to show the state of your custom aura then don't untrigger it

commented

Apologies, I appear to have not been clear.

WeakAuras provides some information within WeakAuras.state, such as the duration, stacks, icon, etc... I commonly want to use this information if the value I want a dynamic information function of a custom trigger to return is identical to that of the previous result. This scenario pops up when a custom trigger listening for an event is evaluated to true, then the next time it's evaluated I want to ignore the event (for example I'm listening for "UNIT_AURA" and the unit is not "player"). Here I just want to return whatever I returned last time generally.

Currently I need to persist that info myself if I want it in the custom trigger functions. It would be nice to simply just be able to use WeakAuras.state.duration if I want the duration info resolved during the last successful trigger.

If that's still not clear I'll respond with a code example tomorrow.

commented

if i get it, your problem is that your trigger return true when it should not

commented

WeakAuras provides some information within WeakAuras.state, such as the duration, stacks, icon, etc... I commonly want to use this information if the value I want a dynamic information function of a custom trigger to return is identical to that of the previous result. This scenario pops up when a custom trigger listening for an event is evaluated to true, then the next time it's evaluated I want to ignore the event (for example I'm listening for "UNIT_AURA" and the unit is not "player"). Here I just want to return whatever I returned last time generally.

In this scenario the way you'd handle it would be to catch only changes which require a Dynamic Info change in the trigger, but have your untrigger code avoid returning true. That will mean that the various Dynamic Info code blocks will not fire unless they need to update their values.

The workaround that Buds mentioned of keeping some info in aura_env between fires gets used a lot too.

commented

There are multiple ways to achive that:

  • return false + return false from trigger/untrigger for events that you want to ignore
  • store information in aura_env and only update them if the event is interesting
  • use a TSU aura that gives you full control over how exactly the states are built.