[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Checking if a group is enabled
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Checking if a group is enabled

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


Posted by Shadoweave   (42 posts)  [Biography] 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).
[Go to top] top

Posted by Nick Gammon   Australia  (21,321 posts)  [Biography] 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
[Go to top] top

Posted by Shadoweave   (42 posts)  [Biography] 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.
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] 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.

[Go to top] top

Posted by Isthiriel   (111 posts)  [Biography] 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).
[Go to top] top

Posted by Shadowfyr   USA  (1,783 posts)  [Biography] 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.
[Go to top] 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.


6,767 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]