Mushclient's scripting infractructure can be indeed confusing if you are used to the TinTin-like model, which is what Zmud's scripting is based upon. In Zmud, all scripting happens literally 'inside' the client, Zmud parses commands you type, figures out what they mean and processes them. Mushclient uses a newer model of embedded scripting, where the actual program (Mushclient in this case) does all of its scripting in a separate module. In Mushclient's case, this module is a Windows DLL representing an interface to a script interpreter, and Mushclient communicates with it using Microsoft's COM. In short - scripts are separate from Mushclient. Scripts can be loaded into Mushclient from a main script file, this is done by editing the file in any text/code editor (e.g. Notepad) and saving it, preferably with a standard extension (.js for javascript). Once you have a script file you need to go to the Scripting dialogue in File->World options (or by clicking on its button on the toolbar), check the 'Enable scripting' option, select a scripting language from the dropdown box, and then browse to your saved script file and open it. If the script file doesn't have any errors it will be loaded into Mushclient. From here on, Mushclient can access any procedure declared in your script file. If you want a trigger to access some procedure you simply put the procedure's name into the 'Script' box of the trigger's edit dialogue. When the trigger fires it will call the procedure with that name. When it does call it it will pass 3 arguments to it, so any procedure that needs to be accessed by a trigger/alias, needs to accept these:
sub ProcName(name, output, wildcards)
name - is the name of the calling trigger/alias
output - contents of the trigger/alias's send box
wildcards - an array of wildcards, same as %-substitutions in Zmud or Mushclient's triggers/aliases: wildcards(0) = %0, wildcards(1) = %1, etc.
Timers are different since they only pass 1 argument - their name:
To call Mushclient from the script, you use callbacks. These are defined in a special object 'World', which is automatically made visible to the scripting engine, so to do an echo you use:
Another common way of using scripts is to put them directly inside triggers/aliases, just type the script in the Send box and select "Scripting" for the Send to option. Nothing needs to be put in the "Script" box in this case. This way you can do pretty much anything that could be done in the script file, it is especially useful for doing simple tasks, like enabling/disabling triggers/aliases/timers/etc, calling a procedure in the script file without having to make it accept the standard number of arguments, etc.
Confusion about the format of triggers/aliases/timers posted here is resolved quite simply - find some trigger with confusing formatting on these forums, copy it (from-to and including the <triggers></triggers> tags), then go to your Mushclient world window, open the Triggers dialogue and hit the Paste button in the lower right corner. The trigger will be added to the list. You can now open it for editing and see what all that syntax means. The same works in the reverse order - make a trigger in the Trigger edit dialogue, click Add, click Copy in the Triggers dialogue, now go to the forums, browse to this thread, and paste the contents of your clipboard into the text form. You will see the XML source of the trigger.
The reason why your example alias isn't working might be that you haven't changed the Send to option. If it's set to "World" then whatever you typed in the Send box will go directly to the mud as-is, and will be misunderstood there. Select "Scripting" and it should work just fine. You can try posting your alias here, using the method above, that way I can give a more specific diagnosis. |