Adding triggers through a script into a group?

Posted by Clanat on Fri 19 Oct 2007 05:03 AM — 9 posts, 33,602 views.

#0
I'm interested in making a script that can be placed on a blank MUSHClient and work correctly, adding the necessary triggers into the proper groups. I looked through the AddTrigger and AddTriggerEx methods, and there doesn't seem to be any way to specify a group for the triggers to go in. Is there any way to do this without having to edit the triggers manually?
Australia Forum Administrator #1
Check out plugins, they will do that pretty much:

http://www.gammon.com.au/mushclient/plugins/
Australia Forum Administrator #2
Also, see http://www.mushclient.com/faq - point 41.
#3
Thanks, sorry I didn't read the FAQ closely enough.
#4

Oh, seems the 'name' is necessary for all the actions.
So this is not I want.

I want a no-name but with-group way to add triggers/alias/timers.
So I can dumping my entries into a script, make my world clean.
Then in my init script, I can:
1. deletegroups('a-group-name')
2. one by one, create a no-name trigger with group 'a-group-name'.
3. disable or enable the group for init state.

Now I lost the handler for created trigger after invoke AddTrigger.
If I didn't define each trigger name, it's hard to locate them, since it is not impossible to read them back and check it's 'match' field :(

Now I must use a replacement way to do that, define each name as 'a-group-name'..dummy_count. It's easy to check the 'name' field.
Australia Forum Administrator #5
See:

http://www.gammon.com.au/scripts/doc.php?function=GetTriggerList

Each trigger will have an internal name (as in that page). Then you can check the group for each one. See:

http://www.gammon.com.au/scripts/doc.php?function=GetTriggerInfo

#6
Thank you, I know the internal name like *triggerNNN.
What I mean is like zmud class. It doesn't care each trigger's name, just care of group.

The scene is:
1. delete the special group
2. create many temporary trigger/alias/timer via a table(maybe), and add to the group.

So it's easy to share between different char on same world, or share to other mudders. Just require the .lua is ok, like plug-in.

To do step 2, now the only way is create it firstly, then get its info using addxml, then change its group.
Now the name is the quick way to get it back, otherwise we need get list, and compare each 'match' field.

BTW, thank Nick for the wonderful and powerful mud client:)
Australia Forum Administrator #7
I'm not quite sure what you are trying to do here.

The logical way of sharing a whole group of triggers, between worlds, or between users, is to simply put them in a plugin. Then you just install that plugin where required.
#8

The trouble is my friends is not good at programming...
So I need to make a simplest way to add their own match text they want. A string table is simple way for it, so I can make the script to read the string, then auto-create the triggers.

Just now I saw another post "Trigger from a dynamic list?", seems 'addxml.trigger' can do 'AddTrigger' behavior, like:
addxml.trigger {
enabled = 'y',
regexp = 'y',
['repeat'] = 'y',
custom_colour = '17',
sequence = '100',
other_text_colour = 'red',
match = '\\\\b(' .. table.concat (names, '|') .. ')\\\\b',
name = 'pkillers',
}
It's enough for me:)

Thank you.