Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ Checking if a group is enabled

Checking if a group is enabled

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Shadoweave   (42 posts)  Bio
Date Thu 22 Nov 2007 07:15 AM (UTC)
Message
I was wondering if there is a commnand to check if an entire group is enabled, something like GetTriggerInfo (sName, 8).
Top

Posted by Nick Gammon   Australia  (23,099 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 22 Nov 2007 06:56 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shadoweave   (42 posts)  Bio
Date Reply #2 on Fri 23 Nov 2007 08:55 AM (UTC)
Message
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.
Top

Posted by Shadowfyr   USA  (1,788 posts)  Bio
Date Reply #3 on Fri 23 Nov 2007 06:03 PM (UTC)
Message
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.

Top

Posted by Isthiriel   (113 posts)  Bio
Date Reply #4 on Sat 24 Nov 2007 03:28 AM (UTC)
Message
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).
Top

Posted by Shadowfyr   USA  (1,788 posts)  Bio
Date Reply #5 on Sun 25 Nov 2007 01:15 AM (UTC)
Message
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.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


22,641 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.