Gammon Forum
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 (22,973 posts) bio
Forum Administrator |
Date
| Reply #1 on Wed 08 Aug 2001 09:48 PM (UTC) |
Message
|
- 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.
- The second argument is the actual matching line, in case you want to work with the line itself.
- 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.
8,949 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.