Jmc object’s methods, properties and events list
All samples here are in Jscript language.
Jmc object properties
- IsConnected
- read-only property. True if JMC connected to MUD server right now. False if not
- Event
– contains jmc object event’s parameter. For “Incoming” and “Input” events contains currently processing line. Also, its contains current line while you calls script from #action command
- Profile
– returns name of current profile. Read-only
- CommandChar
– returns TinTin commandchar. Read-only.
Jmc object methods
- [ShowMe (text, [color])
- displays text on JMC main screen. Second parameter is options. Format of [color] string same as in the
#highlight command. Also, look at #showme command. Sample: jmc.Showme(“aaa”) jmc.Showme(“aaa”, “red”)
Send(text) - send text directly to MUD. Without any processing by JMC TinTin aliases.
Beep() - makes a boop. Same as #bell command.
Parse(command_text) – Parse text by JMC. Text will be parsed by same way as a text typed in commandline. So, every JMC commands processing allowed here . Samples: jmc.Parse(“#alias pk {#var taget}”) jmc.Parse (“kill Pnuk”) jmc.Parse(“#scri MayProc()”)
Output(text, [color]) - display text into “output” window of JMC. Second parametr is optional. Look at #output and #highlight for color format. Samples: jmc.Output(“Wake up ! Time to kill goblins!!!”) jmc.Output(“Death to Shesh(”, “red”)
SetTimer([ID, Interval, LONG preInterval) -Set up ne timer. After you calls this function JMC will generate «Timer» event every Interval/10 seconds and generate «PreTimer» event every PreInterval/10 seconds. ID parameter needed to separate differet timer events. Timer/Pretimer events recives ID as a paramer, so you may have few timer in one time. Calling this function with same ID will reset timer and fource it to start new interval. Samples:
– JMC will generate Timer event every 60 seconds. “Timer” event gets 1 as a parameter.
Jmc.SetTimer(2, 300, 50) – JMC wqill generate event “Timer” every 30 seconds with 2 as a parameter and will generate “PreTimer” event in 5 seconds before 30 seconds interval with 2 as parameter. Now you able to catch ticks every 60 seconds and catch half-tick perionds every 30 seconds.
KillTimer([ID) – kill timer defined by ID. JMC stops to generate timer/Pretimer events for this timer ID.
Eval(text) - One of the most powerful JMC method. Its alolows you to parse csript code from script code. Folloing sample demonstrates «include» implementation by this method:
var FileSystem = new ActiveXObject("Scripting.FileSystemObject");
var ForReading = 1;
var ForWriting = 2;
var ForAppending = 8;
function _include(sFileName)
{
var Stream = FileSystem.OpenTextFile(sFileName, ForReading);
jmc.Eval(Stream.ReadAll());
Stream.Close();
}
- RegisterHandler(EventName, Code) – this method is used for non Vbscipt languages. Only Vbscript language provides default support for events, generated by objects. In all other languages (like Jscript, PERL etc) you must call this method to receive events from JMC. Samples:
Jmc.RegisterHandler(“Incoming” , “OnIncoming()”);
Jmc.RegisterHandler(“Timer”, “OnTimer()”);
- Connect(Address, Port)
- force JMC to connect to remote server.
- DropEvent()
- in the “Incoming” and “Input” event force JMC to do not process line. Both events fires BEFORE JMC parsing,. I.e. every string coming from the MUD firest “Incoming” event, then process by JMC. If you call DropEvent while Incoming event this line will be gaged and will not process by JMC. For input strings JMC fires “Input” event. IF DropEvent called this input will not by processed or sent to MUD.. Also, if you call this method while execute action, it fource JMC to gag this line and don’t display it. Sample: #action {Pnuk standing here) {#showme Damned goblin standing here!!!;#scri jmc.DropEvent()} See also: #drop command.
- Disconnect()
– disconnect JMC from remote server.
- SetHotkey([Key, Command)
– defines new hotkey in JMC. Key format is same as #hotkey command
- SetStatus([StatusNum, Text, bstrColor)
– set text to the status line cell. Same as #status comamnd
- SetVar(VarName, Value, bGlobal)
– set JMC variable value. Sample: jmc.SetVar(“food”, “bread”) jmc.SetVar(“weapon”, “sword”, true). Lok at #variable command.
- GetVar(VarName,)
– returns a value of JMC variable. Sample: food = jmc.getvar(“food”);
Jmc object events
Connected
– Fires every time JMC connected to remote host. No parameters.
ConnectLost - Fires every time JMC loose connect to remote host. No parameters.
Incoming – Fires on every string arrives from the MUD. Event property contains string (with ANSY sumbols)
Input
- fires on every string typed by user in commandline. Event property contains string.
Timer – fires then timer interval, defined by SetTimer method elapsed. Event property contains timer ID.
PreTimer
- fires in PreInterval/10 seconds before timer interval, defined by SetTimer method elapsed. Event property contains timer ID.
Disconnected
– fires then connection to remote host lost, by user’s actions (#zap command etc)
Load – fires then script engine restarting (loading new profile or “Script->Reload script” menu item used)
Unload - fires then script engine destroys(unloading profile or “Script->Reload script” menu item used)