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

Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Jscript
. . -> [Subject]  scripting trigger wildcards

scripting trigger wildcards

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

Posted by Aggressio   (6 posts)  [Biography] bio
Date Wed 23 Mar 2005 01:33 PM (UTC)
For some reason the helpfiles weren't enough for me to understand how to get wildcards from triggers to a script.

The vbscript example didn't tell how to set up the actual trigger, and trying something similar in jscript didn't work at all.

Later noticed that having special characters in the wildcard somehow affected the script and led to problems.

Yet I spent hours to figure out the syntax, reading the help files and going through this forum.

So some examples of setting up different wildcard scripts might be useful. with the trigger-setups.

wildcards like .* and etc. and ofcourse how to use the stuff in a script. %0 %1 %2 ? if ideas for examples are needed perhaps something like script for adding up different types of coins in a purse, or translating a symbol line of [@###:...] into number where @=1000,#=100,:=10,.=0

perhaps some revision in the help-files would be nice too.

[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #1 on Wed 23 Mar 2005 02:50 PM (UTC)
Trigger wildcards can be used in scripts in two different ways. If you use scripting from inside the trigger itself (by putting the script into the Send field and selecting Scripting for the "Send to" option) then you can reference the wildcards just as you normally would in a trigger:

say Hello, %1

where %1 will be substituted by whatever is in the first wildcard. With scripting, however, the wildcards are translated literaly, which could lead to problems if you don't take that into account. For example, if "Fred" is in your first wildcard and you want to send that wildcard through scripting, then the following will generate an error:

world.Send (%1)

That happens because %1 is substituted with Fred, giving you:

world.Send (Fred)

Fred is not a string here, since it's not quoted, so unless you have a variable named Fred, and it also happens to hold a string - you'll get an error. Instead you should do:


Now Fred will be quoted, which makes it a string literal. Of course, not quoting %# is not really a mistake, since you could have a Fred variable, in which case no error would be generated.

If you are using the wildcards in a function inside a scriptfile, then your function should accept 3 arguments, which are in order of appearance:

-name (of the trigger that called the function)
-output (what is in the trigger's Send field)
-wildcards (a list of them)

Here, to get the first wildcard you'll simply get the first element of the wildcards list. For example, here's the Fred example in a script file:

function Fred(name, output, wildcs) {
   world.Send (wildcs(0));

I am not exactly sure if the first wildcard in Jscript is actually at index 0, might be 1.
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Thu 07 Apr 2005 04:42 AM (UTC)
See GetTriggerWildcard.

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


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.


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 HostDash]