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 ➜ Jscript ➜ Question about trigger and script

Question about trigger and script

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


Posted by Lbc   (4 posts)  Bio
Date Wed 08 Aug 2001 09:11 AM (UTC)
Message
there must be 3 argments for a script function if i want

send some values into scritp variables??!!

eg.

Trigger: ^.*Mana:(\s+)(\d+)/(\s+)(\d+)
send:
script:Ongetinfo

//function in script

function Ongetinfo(TriggerName, trig_line, wildcards)
{
var wildcard1 = VBArray(wildcards).toArray();
var Mana = wildcard1[1];
var maxMana = wildcard1[3];
world.note("Mana is " + Mana);
world.note("maxMana is "+ maxMana);
}

i know this will work good, but, i dont know how does it

work, could you explain it to me? :) such as what each

argment means, why the "wildcards" must be the 3rd argment,

etc...

and, is there any other way make it easier to send

something that i got from regexp into script(i want to send

more that one value once a time, so i dont wanna select

"Send to Variable(lable is name)" in list box) ?

if not, will you do it in next version? :P
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 08 Aug 2001 09:48 PM (UTC)
Message

  1. The first argument is the trigger name, in case you want to share the same script between different triggers - by looking at the name you can tell which trigger called it.

  2. The second argument is the actual matching line, in case you want to work with the line itself.

  3. The third argument is an array of the first 9 wildcards that matched, and the 10th item in the array is the whole matching trigger.


There is no particular reason why the wildcards it the third argument, except that was how I wrote the program.

What you have done is about the easiest way of getting wildcards into variables, after all it is only one line per variable, plus one line for the "VBArray(wildcards).toArray();".

The "send to variable" was provided as a shortcut if you only wanted to set a single variable in a trigger.

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


11,038 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.