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 ➜ VBscript ➜ Trigger To script Need Help Please

Trigger To script Need Help Please

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


Posted by Loki_edmud   (5 posts)  Bio
Date Sun 01 Aug 2004 10:31 PM (UTC)
Message
Ok, By looking at some of the posts this question has been asked but I don't understand the answers given.

ok Bascially I was trying out that example on the help file for Trigger sending to script.

I copied and pasted and renamed a VBscript example file
to myscript. Then I copied and pasted the Example code from the help File:

Quote:

Trigger scripts

Triggers can execute script commands by simply putting the command into the "send" box and selecting "send to script".

However for more complex scripts you can put scripts into your script file (see scripting configuration tab for the world) and then call the script from the trigger. To do this put the name of the script subroutine into the trigger's script box.

The script subroutine must have three arguments, as follows:


· Name of the trigger

· The matching line
· An array of the first 10 wildcards


An example script in the VBscript language would be:


sub MyTrigger (name, line, wildcards)
world.Note "Trigger " & name & " matched."
world.Note "Wildcard 1 was" & wildcards (1)
end sub


Wildcard 10 is the entire matching sequence, which is not necessarily the same as the matching line in the case of regular expressions.

Other wildcards can be accessed by using the GetTriggerWildcard script routine (for example, named wildcards, or wildcards over number 9).


My trigger looks like this:
Quote:

<!-- triggers -->

<triggers
muclient_version="3.50"
world_file_version="15"
date_saved="2004-08-01 18:06:27"
>
<trigger
enabled="y"
match="^[EDMUD\: (.*?) has entered the realm\.]$"
regexp="y"
send_to="12"
sequence="100"
lowercase_wildcard="y"
>
<send>MyTrigger</send>
</trigger>
</triggers>
[/qoute]

and I am getting the Following :

Error code: -2146827838

Event: Execution of line 1 column 1

Description:
Wrong number of arguments or invalid property assignment: 'MyTrigger'
Line in error:

CalledBy:
Immediate execution

I know that I am missing something simple, it has has been a long time since I have worked with any code or scripting.
It is like a diffrent language to me now. I would appreaciate any help possible... Thank You very much.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 01 Aug 2004 11:41 PM (UTC)
Message
You are mixing two different methods here. If you have the script in a script file, then you just put its name (MyTrigger) in the "script" box in the trigger dialog, and leave the "send" text blank.

Or, you can put what you actually want to do in the "send" box and "send to script". eg. in the "send" box you might put:

world.Note "Trigger " & name & " matched."
world.Note "Wildcard 1 was %1"


Note that in this case you simply use %1 for wildcard 1, as there is no subroutine call in this case.


Quote:

match="^[EDMUD\: (.*?) has entered the realm\.]$"


This will not be a big success. Things in square brackets are simply a group of letters to match.

eg.

match = "[cat and dog]"

This will *not* match the sequence "cat and dog" as you appear to expect, but a *single* letter, consisting of any of the letters "c", "a", "t", " ", "a", "n", "d", "d", "o", "g".

If you actually see the square brackets then they need to be escaped with a \ before them.

(edit)

Looking at your post in more detail I see the \ is actually there. When posting to the forum you need to double them up (like "\\[") as the sequence \[ has a special meaning to the forum.

You can use MUSHclient's notepad, paste the trigger there, select all and choose "Convert -> Quote Forum Codes" to do that automatically.

- 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.


10,814 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.