ActiveScript support in JMC 3.*
Well. JMC 3.0 now support active scripting. What is it ? Its means you are able to use scripts, written in “real” languages. But you should not write you script on some specific language. ActiveScript technology allows you to choose language. Microsoft Scripting includes 2 languages: JScript and VBScript. There are few third-party ActiveScript languages: PERL, TCL and some more. You may find languages in the Internet and install on your computer.
Why do you need to use powerful scripts ? If you are experienced user, you do know: TinTin scripts are not allows you to work with arrays, to manipulate strings, to check complex conditions. So, you need more powerful tool to make complex and useful autoactions, to collect some info while you playing mud etc .
Why don’t use other MUD client with more powerful internal script ? I tested a lot of them – none have really complex language tools, none could be powerful and smart. What why I adds script support to JMC.
Introductions. How its working
Getting started.
Every time JMC starting or loading new profile it initializing script engine. Script engine (language) you may choose in ‘Options” dialog , “:Scripting” page. JMC loads 2 files with scripts:
JMC parse scripts from both files and script engine ready for job now. You may reinitialize script any time by “Scripting/Reload script” command. This command destroys current state of script and reload files.
You should understand parsing algorithm. Scripts are parsed and executed. What its means ? Its means some potions of code executed “inplace”. Its something like:
Var MyName = “jaba”;
Count = 11;
MsgBox (“We Starts !!!!);
But functions definitions are “parsed” and stored in script engine. Now script engine are ready to execute function , but in don’t execute function until it called:
Function KillEveryone(){
Taget_name = “all”;
}
While parsing JMC adds KillEveryone function to namespace and now you able to call function any time:
KillEveryone(); // now Taget_name variable contains “all” string.
How to call functions, execute statements, add new functions while JMC running ?
There are 2 ways to execute portion of script code. First way is #script command. But its allows you to use only small, simple, one-line potions of code. You may add new potion of code by “Scripting” menu, “Add scriptlet” dialog. In this dialog you may write and parse something complex code like this:
Function k (line) {
Jmc.send(“kill “ + line);
}
This dialog may be called by Ctrl+1 button, toolbar button or by menu/. You may hide dialog by ESC button and continue work any time. Also, dialog keep all potions of code you entered and both .SCR files code. Its useful to find some function and change it code.
Interrupting script.
Sometimes, you may need to interrupt script ( for instance, you did endless loop). You mat do it by "Scripting/Break" command.Inportant.
To dont loose your scriptlets, added by "Add scriptlet" dialog JMC automatically saves all scriptlets, added in current session into Settings\union.scr file while profile saves. So, you may move new scriptlets to your <profile.scr> file later.How scripts interacts with JMC , MUD and TinTin commands ?
You are able to create functions, variables etc in script. But script language have no any interface functions. There are no functions do display something, to ask input, to work with IP connections etc. How are script may be connected to JMC ?
There is one way to do it. Script languages may use “:objects” . Object nay be created inside script, by CreateObject or GetObject functions (see language reference ). You may create any automation object registered in your system. For instance, you may create “exel.document” object and operate with it. But there are few predefined objects you may use from scripts. JMC supplies one object to interact with JMC interface and MUD connection. This object named “jmc”
“jmc” object provides methods, properties and fires events. You may use them to work with JMC. For instance, \if you want to send some string direct to MUD server do something like this:
jmc.send(“this text sending to MUD right now”);
Full list of jmc object methods is in next paragraph.
Jmc object provides functions to display text, to send it to MUD server, to parse text by TinTin commands, to evaluate scriptlets etc etc.
Events. What is it and how to use it ?
Jmc object supply’s methods to display text and send text to mud. But more important goal is to parse strings< incoming from MUD and strings inputted by user. You need it to create triggers, aliases, highlights etc etc.
Obvious, you are able to use TinTin triggers to work with incoming text:
#action {%1bashed%2} {#scri OnBashed(%0)}
But it isn't right way.
JMC inform scripts every time some event occurred. Events is : text incoming from mud, text inputted by user, timer, profile loads, connection lost, JMC connected to mud etc.
Jmc object fires event every time it arrives. Now, you able to handle jmc object events in scripts. ATTENTION !!!! There ere 2 ways to handle events. VBScript users must just create subroutines with appropriate name:
Sub Jmc_<Event_name>(<param>
End sub
Sample:
Sub Jmc Incoming (line)
Jmc.Output «We got line from mud:» + line, «red»
End sub
Now, every time string arrives from the MUD this subroutine will be called.
ATTENTION !!!! Event handler subroutine MUST have same parameters s jmc's event. For complete list of JMC event look next paragraph.
Other languages users should register event handlers by calls:
jmc.RegisterHandler(«event_name» , «script code»);
Sample (Jscript):
Function OnIncoming() {
Jmc.Output («We got line from mud:» + line, «red»);
}
jmc.RegisterHandler(«Incoming» , «OnIncoming()»);
Incoming and Input events and parameters.
Jmc fires Incoming event every time text arrives from the mud. JMC fires Input event every time user enter line. Obviously, you should have way to CHANGE those strings. Ie. You must have chance to «gag» incoming string, to prevent it displaying, to change inputted line etc. You may do it by jmc property Event and jmc method DropEvent.
IN THOSE TWO EVENTS jmc.Event property contains string. You may change it and JMC will work with changed string. Sample:
Function OnIncoming(){
Var line = jmc.Event;
If ( line.search («Johary» ) ) {
Line.replace ('Johary» , «JOHARY THE EVIL MAN»);
Jmc.Event = line;
}
}
Now the word 'Johary» will be changed to «JOHARY THE EVIL MAN» in any strings incoming from MUD.
Function OnInput(){
if ( jmc.event == «aaa» ) {
jmc.showme(«Don’t type stupid aaa command!!!!!»);
jmc.DropEvent();
}
}
Now any time you type «aaa» string it will not be send to mud and executed by JMC's tintin scripts.
Jmc script debugging support
JMC 3.0 provides some support for debugging scripts. to do it go "Options/Scripts" dialog and turn "Allow debugger" ON. then restart JMC. Now script debugger will be started every time error arrives while script runs. Also, you may run debugger and set up breakpoints, if you want to trace script execution.
For complete list of JMC object propertyes, methods and events look at JMC object description page