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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Loading Triggers and Aliases Question

Loading Triggers and Aliases Question

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


Posted by Boca   (15 posts)  Bio
Date Thu 19 Jul 2001 10:11 AM (UTC)
Message
1. I have a lot of triggers and aliases from ZMUD that I would like to import to MushClient. What format do they need to be in, and how would I go about doing this?
I tried looking up Load and Import in the help, but no luck there.

2. In ZMUD I could export my settings, work on them with notepad and import them again. Can I do the same thing with MushClient?

Thank you for your help on my first post, syntax is everything :)

Boca (who is now has some aliases and triggers working)
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 20 Jul 2001 12:52 AM (UTC)
Message
There is no import facility right now, although you could do it with a script that did a whole lot of "addtrigger"s.

However I am a bit doubtful how useful that would be, as zMUD and MUSHclient use different regular expressions for one thing, and zMUD has inline scripting, whereas MUSHclient calls scripts in a script file.

If they were simple triggers/aliases, which were not regular expressions, and did no scripting, then it could probably be done quite easily.

Perhaps if you export the triggers/aliases you are interested in, and post them here, or email them to me, I'll see if it could be done. If so, I'll do a script that would import them, and you could use that.

- Nick Gammon

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

Posted by Boca   (15 posts)  Bio
Date Reply #2 on Fri 20 Jul 2001 01:59 AM (UTC)
Message
I can copy and paste most of my triggers/aliases over with no problem. However, I have some complicated triggers that I would not know how to do in MushClient. Following is one of them which is very important to me - it takes a TEST emote from the leader and automatically creates a trigger to pick up the target. So if the leader is Ohio and he emotes this: Ohio will send the TEST to the moon!
this trigger is created: ^Ohio will send the (%w)

then the mob is loaded to the variable target and
I show the target (only to myself) on the screen.

How would this be done in MushClient?

Here is the ZMUD trigger
Pattern: ^@leader (*)TEST(*)
Value: #UNTR {^@leader %1(%w)}
#TR {^<@leader> %1(%w)} {
#var target %%1
#show Target is ~>~> @target ~<~<
}

I decided to go ahead and register my copy of MushClient, I am very impressed by your responsiveness.
Thank you for your continued support.
Boca
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #3 on Fri 20 Jul 2001 10:21 PM (UTC)

Amended on Fri 20 Jul 2001 10:25 PM (UTC) by Nick Gammon

Message
OK - I have worked out a replacement for that, I think. :)

MUSHclient doesn't let you put variable names into the trigger match text (however you can use them in the trigger response), so as I see it you have three steps here:

1. Define who the leader is, so the first trigger matches properly.
2. Make a trigger that matches on the leader sending the TEST line
3. Make a trigger that matches when the leader changes targets

First, I made an alias to detect the name of the leader changing:


Alias: LEADER *
Enabled: checked
Label: Leader
Script: OnLeader


Then add the following lines to your script file, or make a new script file with them in it. Language: VBscript.



sub OnAddTarget (strTrigger, strLine, strWildcardsArray)
dim leader
dim target

leader = world.getvariable ("leader")

' flags =
'    1 = enabled
'   32 = regular expression
' 1024 = replace existing trigger of same name

world.AddTrigger "PickUpTarget",  _
        "^" + leader + " " +     _
          strWildcardsArray (1) + "(.+)", _
        "", 1 + 32 + 1024, -1, 0, "",  _
        "OnNewTarget"  ' function to call
end sub

sub onNewTarget (strTrigger, strLine, strWildcardsArray)

world.setvariable "target", strWildcardsArray (1)
world.note "Target is >> " + strWildcardsArray (1) + " <<"

end sub

sub OnLeader (strAlias, strLine, strWildcardsArray)

world.setvariable "leader", strWildcardsArray (1)

world.AddTrigger "LeaderEmote",  _
        strWildcardsArray (1) + _
        " (.*)TEST(.*)", _
        "", 1 + 32 + 1024, -1, 0, "",  _
        "onAddTarget"  ' function to call

world.note "Leader is >> " + strWildcardsArray (1) + " <<"

end sub



There are three subroutines (subs) here, which I have made in bold, although in practice you would not use bold.

OnLeader is called from the alias, and adds the trigger "LeaderEmote" which matches on the name of the leader (wildcard 1) saying (.*)TEST(.*). It also displays the leader name on the output window as confirmation that it matched. Note the alias is case-sensitive.

Thus, you might type:

LEADER Ohio

Then when the leader emotes his line "Ohio will send the TEST to the moon!" this calls the trigger labelled LeaderEmote which calls the sub OnAddTarget.

This sub generates the third trigger, that matches on the target's name.

Have fun with it. :)

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #4 on Fri 20 Jul 2001 10:28 PM (UTC)
Message
When I look over my answer I think it might be too complicated, but let me know if I have misunderstood the question. :)

- Nick Gammon

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

Posted by Boca   (15 posts)  Bio
Date Reply #5 on Fri 27 Jul 2001 02:01 AM (UTC)
Message
You answered my question, but I don't understand this syntax for the line starting with strWildcardsArray (1):

world.AddTrigger "PickUpTarget", _
"^" + leader + " " + _
strWildcardsArray (1) + "(.+)", _
"", 1 + 32 + 1024, -1, 0, "",
Could you explain it please?

Also, you very nicely commented in the script what the flags 1, 32, and 1024 meant - is there a list of them somewhere?
What is the -1 and 0?

Sorry to be so dense, but this stuff reads like a foreign language to me.

One more question - I will be picking up the leaders name from a trigger: ^You now follow (*)
could I send something like this to the mud to load the variable leader?

/world.setvariable "Leader", %1

Thanks,
Boca
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #6 on Fri 27 Jul 2001 03:46 AM (UTC)
Message
It is all documented in the functions page:


http://www.gammon.com.au/mushclient/functions.htm


Quote:

One more question - I will be picking up the leaders name from a trigger: ^You now follow (*)
could I send something like this to the mud to load the variable leader?

/world.setvariable "Leader", %1



You only use the slash when typing a script function into the command window. In a script itself it isn't needed. To get the first wildcard you would do this:


world.setvariable "Leader", strWildcardsArray (1)






- Nick Gammon

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

Posted by Boca   (15 posts)  Bio
Date Reply #7 on Sun 29 Jul 2001 06:18 PM (UTC)
Message
I loaded the alias and script which set the leader and created the target emote (exactly as you described below in the message dated Fri 20 Jul 2001 10:21 PM).

The trigger being created is picking up everything from the TEST on as part of the target. Here is a real example:

The alias to set leader (Leader Solace) works fine and I get:
Leader is >> Solace <<

and it called a script which created this trigger:
Solace (.*)TEST(.*)

When the TEST emote was given (Solace will send the fido to the moon!), it called another script and created this trigger:
^Solace will send the (.+)

then when Solace emoted a target next (Solace will send the fido to the moon!), this is what I got:
Target is >> fido to the moon! <<

So it picked up everthing from the TEST on as the target. How can I fix this?

Thanks,
Boca



Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #8 on Sun 29 Jul 2001 10:00 PM (UTC)
Message
In the trigger that matches on TEST you need to change the trigger it generates slightly.

It needs to match on: (\w+) .*

This will match on one word, and then discard whatever follows that word.

In other words, change the AddTrigger slightly, the changed part is in bold:


world.AddTrigger "PickUpTarget",  _
        "^" + leader + " " +     _
          strWildcardsArray (1) + "(\w+) .*", _
        "", 1 + 32 + 1024, -1, 0, "",  _
        "OnNewTarget"  ' function to call




- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


28,564 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.