How to use world.getTrigger(), world.getAlias()

Posted by Unregistered user on Mon 24 Jul 2000 12:00 AM — 6 posts, 25,951 views.

#0
How does one use the function mentioned above? A simple example which first defines a trigger and then retrieves its details with getTrigger would be nice.

Thanks

- skj
Australia Forum Administrator #1
There are a lot of examples for doing these things in the web page: http://www.gammon.com.au/mushclient/functions.htm

Triggers

Here is an example of adding a trigger:

/World.addtrigger "monster", "* attacks", "flee", 1, 14, 0, "", ""

Now to get it back ...

/world.gettrigger "monster", trmatch, trresponse, trflags, trcolour, trwildcard, trsoundfilename, trscriptname

Display some of its values ...

/world.note trmatch
/world.note trresponse

These examples are in VBscript, the JScript ones will be very similar.

Aliases

Add an alias ...

/world.addalias "teleport_alias", "teleport", "@tel #1234", 1, ""

Now get it back ...

/world.getalias "teleport_alias", almatch, alresponse, alparameter, alflags, alscriptname

Display some of its values ...

/world.note almatch
/world.note alresponse
#2
function alias( aid, output, wildcards )
{
if ((lst = world.getAliasList()) != null)
{
lst = new VBArray(lst).toArray();
var amatch, aresponse, aparam, aflags, afunc;
for (i=0;i<lst.length;++i)
{
world.getAlias(
lst , amatch,aresponse,aparam,aflags, afunc
// what's this parameter thing anyway (aparam)?
// it's not explained in any of the docs I've
// read, and the addAlias function doesn't
// take such an argument, although according to
// the documentation it should
);
world.note(
lst[ i ] + " =
\"" + amatch + "\",
\"" + aresponse + "\",
" + afunc
);
}
}
}

// Thanks for your quick response Mr Gammon

- skj
Australia Forum Administrator #3
Well, for a start the line:

world.getAlias
(lst, amatch, aresponse, aparam, aflags, afunc);

should read ...

world.getAlias
(lst [i] , amatch, aresponse, aparam, aflags, afunc);

because you want to get the information for alias "i" from the list.

(I suspect you keyed in the [i] however the forum interprets [i] as an EzCode for italic.).

However, I am still having problems getting this to work - it seems to work in VBscript, however I get a "type mismatch" in JScript.

I will research this and post another reply in the forum ASAP.


Parameter

The argument "aparam" is a throwback to earlier versions of MUSHclient, where aliases only supported a single "parameter" rather than wildcards like it does today.

However, to be consistent with older scripts, the argument "aparam" has been left in. It doesn't do anything any more.
#4
I thought as much. I suppose I might as well use VBScript, it's just that I hate the syntax.

- skj
Australia Forum Administrator #5

For reasons that are a bit obscure to me, GetAlias and GetTrigger do not work when called from JScript or PerlScript.

Thus, I have added two new routines, which will appear in version 3.02 - GetAliasInfo and GetTriggerInfo.

These return information about the alias/trigger, using different syntax that does work in any scripting language.

For instance, here is how you would get what a trigger matches on, in JScript:

world.note(world.gettriggerinfo ("monster", 2));

See the web page http://www.gammon.com.au/mushclient/functions.htm for more details.