Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Killfile
Novice


Joined: 30 Sep 2002
Posts: 32
Location: USA

PostPosted: Thu Feb 20, 2003 2:03 pm   

Javascripting
 
So as it turns out Zmud has javascript support. Whoda thunk?

I've started messing with this (as Javascript is much better for complex logical constructions than Zscript) but have run into a problem... rather several problems all steming from the same source. The documentation for Javascripting with Zmud is nearly non-existant (at least that I've been able to find).

Sooooo... how do I....

- Address captured variables, say from a trigger. Does %1, %2, %3 still work?
- Call normal Zmud functions like #BEEP and #SAY, etc?
- Send commands to the mud itself rather than internaly to the script?

Also...
- What kind of object addressing does Zmud use? Is it some derivation of DOM0, DOM1, or DOM2 (God forbid) and if so, what is the standard higherarchy?

I'm sure I'll come up with more tantilizing questions to boggle the mind and pillage the sences later. For now, back to mudding.



--Killfile
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Feb 20, 2003 4:49 pm   
 
There is documentation on this, but since it is not specific to any language, it might not be very obvious. Basically, you have to do all of this through zMUD's zMUDSession COM object. zMUD already provides you with an object, called sess, that references the zMUDSession object of the current session, so all you have to do is call its methods.

Retrieve %1, etc.:
sess.ExpandStr("%1")

Call normal zMUD commands:
sess.ProcessCommand("#BEEP")
sess.ProcessCommand("#SAY testing")

Send commands to the mud rather than the script:
sess.SendStr("look")

or:
sess.ProcessCommand("look")

You can also use zMUDCommand to execute one of zMUD's command, but this is more troublesome. To learn more about the zMUDSession object, look in here.

Kjata
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Feb 20, 2003 11:16 pm   
 
The other option when using external scripting languages mixed with zScript is to use the zScript commands and functions to specifically process portions of code. The commands and functions are #SCRIPT, #SS, #MSS, and %mss. They are not documented in the help file currently, but should be quite nicely documented by the next beta/public version; in the meantime use the Command and Function wizard to look up what arguments they take.

A quick example, not sure if I got it right:
#TR {^(%w) says ~"hello.~"$} {#VAR a {%1};#MSS {b="%1"} {javascript};#IF (%mss(b)) {#BEEP}}

%1..%99 are expanded before the zScript is even sent to the parser, so they will always work. The #SS command is used internally for external scripts, so the parser does get involved, but you never notice.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net