Checking if a group is enabled

Posted by Shadoweave on Thu 22 Nov 2007 07:15 AM — 6 posts, 29,822 views.

#0
I was wondering if there is a commnand to check if an entire group is enabled, something like GetTriggerInfo (sName, 8).
Australia Forum Administrator #1
No there isn't, because you could enable a group and then disable one of the members of it.

The only way would be to iterate through all triggers (or aliases or whatever you are interested in), checking to see which group they are in, and making sure each one with a particular group name is enabled.
#2
Thank you, I have just made a variable that sets itself to 1 when the group is enable, and 0 when the group is disabled, and when I do the check I set it to nil.
USA #3
Hmm. If anyone wanted to change it though.. One could make it return *either* true/false or a count. I.e., if all are on, then true, if all are off, then false, otherwise return the number that "are" enabled. Then all you would need to do to check if your "group" is off is:

if isgroupenabled("mygroup") = vbfalse or isgroupenabled("mygroup") < 2 then ...

Presuming that you had one trigger you might turn off/on within the group independent of the rest of them. Same for testing if all are enabled "except" one, which you don't want to disable.

Mind you, the other alternative would be to have a flag, like, "DisableGroupEnable" (got to be a better name...), in the triggers themselves, so that you can specifically *exclude* one that is part of a set, but which you don't want enabled/disabled via the group system. You might want this anyway, since its convenient to group something like a trigger used to *start* data capture with the ones that are used to do the rest of the captures, but you don't necessarily want to disable it along with the entire rest of the group when you shut them down again. Being able to group a trigger, but selectively exclude it from certain commands effecting that group would be useful. Not that simply re-enabling that one trigger is that hard, just mildly annoying if you forget to do it.

#4
Or you could write your own utility functions in Lua (or Python, JScript ...) that do just that using the existing API.

Making Trigger<->Group a many-many relationship would be better than just adding a "DisableGroupEnable" flag (also, that flag has got to have one of the more confusing names ever :P).
USA #5
Yeah. I tried to think of one that would be better and they only got worse. lol A many to many case could be useful in some cases, I suppose, so yeah, that could be interesting. Perhaps subgrouping. I.e., you could have a set that belong to "combat", with a sub-category of, "spell caster", with a sub-sub-category of "mage", "druid", and so one, or "fighter", with subs for "monk", "weapon master", and so on, where "some" of the triggers might exist in most than one subgroup, but you still want to disable the entire subgroup, depending, in this example, on which type of character you are playing.

Its and interesting thought, though, you *still* have the same problem unless you "name" every single trigger you plan to have in sets, so you *know* which ones are in which group. However, that is the advantage of existing groups. The triggers themselves don't need to be named, just assigned to the right set. You lose that if the system used has to be done via Lua.

Now, one solution would be to adjust the code for handling names, so you could do something like:

group="combat:caster:mage,druid"

You could disable "combat:caster", "combat", or "combat:caster:mage", the later would disable anything that had the "mage" designation (and any shared with druid by the ",", but not those *specific* to "druid". Getting a druid character up would be a simple matter of doing:

enablegroup "combat:caster", vbfalse
enablegroup "combat:caster:druid", vbtrue

Or, you could have a "enableuniquegroup" function, which "only" disabled the ones that had "mage", but *not* "druid" in them.

Or, you could code something in Lua to do that, but you would have to set it up to auto-name triggers, so they are grouped properly. And you lose the ability to use the feature in anything other than Lua that way, **or** changing the display code to take advantage of the sub-category list in the trigger list, if you wanted to make things a lot nicer.