macro scripting

Posted by Wuliao on Mon 20 Aug 2001 07:22 PM — 6 posts, 23,711 views.

#0
I am not sure this is a valid suggestion. But ...

I just hope the macro definition can call functions in the scripts.

For example,

define F2 Key to call a function test

....

function test()
{
world.note ("test");
world.send ("test");
}

....
Australia Forum Administrator #1
You can do this in two steps ...

  1. Make a macro (eg F2) that sends a word (eg. "foobar")
  2. Make an alias that matches on that word ("foobar") - the alias then calls the script.


Because the alias "catches" the word it does not actually get sent to the MUD. You could extend this to have lots of macros that call different scripts. You should probably make up a nonsense word that you would never need to actually send, otherwise the alias would match it, and you could not send that word to the MUD. eg. "ljhlkasj8734587".

The same technique can be used to match on what you press on the numeric keypad. There was a post about that a while ago. For example, if you press "6" on the keypad to go east, the alias could pick that word up and remember which way you last walked.
Australia Forum Administrator #2
However be aware that aliases call functions with three arguments, so the script would actually look like this:


Sub Test (thename, theoutput, thewildcards)
world.note ("test");
world.send ("test");
End Sub
#3
I tried the method. It seems to me the mushClient will not accept the character replaced by the macros as alias.

I mean if I have a function

function doQuest()
{
// which processes complicated task
}

I have an alias defined as
qd for doQuest()
and defined F2 as qd

If I press F2, it will send qd to the world, instead of running the alias.
Australia Forum Administrator #4
You make the alias like this - (it works because I tested it) ...


Alias: qd
Send: (nothing)
Label: Quest
Script: doQuest


Then in the script file you have:


function doQuest(strAliasName, strOutput, wildcardsVB)
{
// which processes complicated task
}


#5
It works! I guess I forgot something before.

Thanks