#Trigger that COUNTS injured party members

23 messages · Page 1 of 1 (latest)

toxic widget
#

Is there a way to create a trigger that filter or count based on the NUMBER of injured party / raid members?

Thanks in advance

abstract pollen
#

yes, but it requires a bit of custom code

toxic widget
#

can you point me to an example that i can see?

abstract pollen
#

no, I can't think of an example

earnest trout
#

You could use a Watched Trigger on a health trigger using the Group unit tag

loud flax
#

t1 = custom - TSU - events = TRIGGER:2
t2 = unit - health - smart group - % < 100

t1 custom trigger:

function(allstates, event, triggerNum, triggerStates)
  if triggerNum == 2 then
    local count = 0
    for _, state in pairs(triggerStates) do
      if state.show then
        count = count + 1
      end
    end
    allstates[""] = allstates[""] or {show = true}
    allstates[""].count = count
    allstates[""].changed = true
    return true
  end
end
toxic widget
earnest trout
#

You can access it as %count in text replacement. If you set .value instead then that's the default progress variable for static clones, which would work with %p for example, and also for controlling something like bar progress

toxic widget
#

ok, i got the text to work

#

since it overrides count, i could just use count in a conditional like normal then?

#

If i'm being unhelpful, What i'm trying to do is be able to hide (or 0% alpha) an icon based on how many party/raid members that have taken damage

earnest trout
#

Don't use conditions for visibility

#

You can just set .show in the custom trigger

#

E.g. allstates[""].show = count > X

#

If you want to use a value that you set in a TSU, in a condition, you have to register it in the "Custom Variables" code box ```lua
{
count = "number",
}

toxic widget
#

ok. yea i don't need to set the custom variable

#

so i add
allstates[""].show = count > X
to the bottom with all of the other allstates lines?

#

and obviously set X to whatever i need it to be?

earnest trout
#

You can, if you do that then, allstates[""] = allstates[""] or {show = true} can also just become allstates[""] = allstates[""] or {}

toxic widget
#

and what number i need between {} ?

earnest trout
#

Nothing, you can just remove the show = true from making the initial state since you're going to set it later

toxic widget
#

i think i understand, let me try it