[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Jscript
. . -> [Subject]  function AddTriggerEx sciptName is not work in javascript
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

function AddTriggerEx sciptName is not work in javascript

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


Posted by Spark   (6 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] top

Posted by Spark   (6 posts)  [Biography] 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);
[Go to top] top

Posted by Kyrock   (20 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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="^[&gt;]*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
[Go to top] 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.


3,841 views.

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

Go to topic:           Search the forum


[Go to top] 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.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]