Question about trigger and script

Posted by Lbc on Wed 08 Aug 2001 09:11 AM — 2 posts, 12,425 views.

#0
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
Australia Forum Administrator #1
  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.