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
➜ function AddTriggerEx sciptName is not work in javascript
|
function AddTriggerEx sciptName is not work in javascript
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Spark
(6 posts) Bio
|
| Date
| Sat 29 Sep 2012 06:42 AM (UTC) Amended on Sat 29 Sep 2012 06:51 AM (UTC) by Spark
|
| Message
|
long AddTriggerEx(BSTR TriggerName, BSTR MatchText, BSTR ResponseText, long Flags, short Colour, short Wildcard, BSTR SoundFileName, BSTR ScriptName, short SendTo, short Sequence);
the parameter ScriptName is work well in lua but fail in j(ava)script.
lua:
function testaa(name, line, wilds)
Note("Name -- " .. name)
Note("Line -- " .. line)
Note("wild-0 " .. wilds[0])
Note("wild-1 " .. wilds[1])
end
jscript:
function testaa(_n,_l,_w){
world.note ("_n="+_n);
world.note ("_l="+_l);
world.note ("typeof(_w)="+typeof(_w));
world.note ("_w="+_w);
world.note ("_w[0]"+_w[0]);
world.note ("_w[1]="+_w[1]);
}
and then i create a trigger by UI,and set pattern as "^you say:(.*)$"
,also set scriptName by "testaa",choise diffrent language,and get diffrent result
lua:
Name -- *trigger97
Line -- you say:ffasdf
wild-0 you say:ffasdf
wild-1 ffasdf
jscript:
_n=*trigger97
_l=you say:ffasdf
typeof(_w)=unknown
_w=
_w[0]undefined
_w[1]=undefined
i doubt that it is a bug . and i guess it is same to alias and triggle .
so i don't know how to solver the problem.
by the way ,i test above in ver 4.83 and v4.73,and get the same result. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Sat 29 Sep 2012 06:52 AM (UTC) |
| Message
| | I don't see any example code that does AddTriggerEx in your post. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Spark
(6 posts) Bio
|
| Date
| Reply #2 on Sat 29 Sep 2012 07:00 AM (UTC) Amended on Sat 29 Sep 2012 07:25 AM (UTC) by Spark
|
| Message
| at firsttime,i write in code,but i cannot get the variablevalue,so i create a trigger from UI for test. the code like this:
world.AddTriggerEx (
"tmp_mapper_"+world.GetUniqueNumber (),
"^[>]*you say:(.*)$",
"",
(17465+32768+512),//eEnabled+eTriggerRegularExpression+eIgnoreCase+eReplace+eTemporary,
3,//custom3,
1, //wildcard
"",
"testaa",
0,//1
2);
| | Top |
|
| Posted by
| Kyrock
(20 posts) Bio
|
| Date
| Reply #3 on Mon 08 Oct 2012 11:45 PM (UTC) |
| Message
| | In lua you can access wildcards directly. In jscript you either have to turn wildcards into a VBArray or use the getTriggerWildcard method provided by mushclient. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,166 posts) Bio
Forum Administrator |
| Date
| Reply #4 on Tue 09 Oct 2012 04:41 AM (UTC) |
| Message
| If you do a Note you can see what the function returned. Using your example:
Note (world.AddTriggerEx (
"tmp_mapper_"+world.GetUniqueNumber (),
"^[>]*you say:(.*)$",
"",
(17465+32768+512),//eEnabled+eTriggerRegularExpression+eIgnoreCase+eReplace+eTemporary,
3,//custom3,
1, //wildcard
"",
"testaa",
0,//1
2));
I see 30009 (the function testaa does not exist).
Now if I add the function, like this:
function testaa(_n,_l,_w){
world.note ("_n="+_n);
world.note ("_l="+_l);
world.note ("typeof(_w)="+typeof(_w));
world.note ("_w="+_w);
world.note ("_w[0]"+_w[0]);
world.note ("_w[1]="+_w[1]);
}
Note (world.AddTriggerEx (
"tmp_mapper_"+world.GetUniqueNumber (),
"^[>]*you say:(.*)$",
"",
(17465+32768+512),//eEnabled+eTriggerRegularExpression+eIgnoreCase+eReplace+eTemporary,
3,//custom3,
1, //wildcard
"",
"testaa",
0,//1
2));
I see 0 (success) and the trigger is added, like this:
<triggers>
<trigger
clipboard_arg="1"
custom_colour="4"
enabled="y"
expand_variables="y"
ignore_case="y"
keep_evaluating="y"
match="^[>]*you say:(.*)$"
name="tmp_mapper_265"
one_shot="y"
regexp="y"
script="testaa"
sequence="2"
temporary="y"
variable="tmp_mapper_265"
>
</trigger>
</triggers>
So, it does work. |
- 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.
22,950 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top