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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
derekconlon
Newbie


Joined: 25 Nov 2015
Posts: 8

PostPosted: Wed Nov 25, 2015 4:45 pm   

cMUD and Javascript
 
I hope this is a simple question but I'm trying to learn how to use Javascript in cMUD.

I'm making a very simple alias to begin the learning.

The alias is called "jscripttest"
and the code is:

var whichrow = 1;
alert(whichrow);

The language is set to jscript, but when I type "jscripttest" it gives the error:

Error Parsing Command:
Object expected [Microsoft JScript runtime error]
(source not available for runtime errors)

My question is, how exactly do you get a cMUD trigger or alias to use Javascript instead of zscript.
I've been learning ZScript and it generally does what I want it to do but I also want to be able to use javascript for things zscript can't achieve.

Are there any instruction manuals or anything like that to help me through?
The internal help for #SCRIPT i cant get working
Syntax: #SCR script language

when i put "#SCRIPT {alert("Hi!");} "JavaScript" it just gives a VBScript error. I've tried many different ways to use that command and it always fails.

I then thought "oh just change the language to JScript" but then I don't know how to output to the CMUD window or anything.

Just need a basic "here's how you do basic things" manual and i'd be able to figure out the rest i'd hope.

Thanks for any assistance.
Derek Conlon
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Wed Nov 25, 2015 5:02 pm   
 
I have never tried myself.
But you can always double check the the language choice saved properly.
I cant help you with the jscript syntax itself, but perhaps someone could verify that it is done properly.

What exactly is it that you feel can't be accomplished with zscript?
_________________
Discord: Shalimarwildcat
Reply with quote
derekconlon
Newbie


Joined: 25 Nov 2015
Posts: 8

PostPosted: Wed Nov 25, 2015 5:44 pm   
 
Right now the only thing that ZScript is lacking that I have needed recently is a "Does not match" abililty. the =~ does "match" but what about if "not match". am I just missing something?

For Example, I pull data from a SQL field that contains different flags that an item has.

If the Item has "INIVISIBLE" and "DETECT_INVISIBLE" both and you want it to show "INVIS" and "DI" when doing a list at a merchant, I had to do this: (full code below)

#IF (@ichk.Item("eff") =~ "INVISIBLE") {
#IF (@ichk.Item("eff") =~ "DETECT") {} {p2 = "INVIS "+@p2}
}
#IF (@ichk.Item("eff") =~ "DETECT_INVISIBLE") {p2 = "DI "+@p2}

The other issue I'm having is, the more complex ZScript code I'm writing seems to lag my CMUD (in windows 10, I never noticed this in Windows 7)
Like when the mud is going fast and lots of data is coming through the cursor goes back and forth between "waiting" and regular cursor and it just lags me.

This script also lags and I think it would run faster with Javascript (maybe it would not but I want to learn how to do it with Javascript to find out)

#SQLDB Arctic.db

//tsql = "SELECT * FROM lores WHERE realname LIKE "
//tsql = %concat(@tsql,"'",%replace(%lower(%4),"'","''"),"'")
//row = %sql(Arctic ,@tsql)
p1 = %1
p2 = ""
p3 = 0
p4 = %4

***** THESE SPACERS ACTUALLY HAVE SPACES IN THEM THAT DO NOT PROPOGATE TO THE HTML PAGE ******

spacer1 = " "
spacer2 = " "
spacer3 = " "
spacer4 = " "
spacer5 = " "
spacer6 = " "
spacer7 = " "
spacer8 = " "
spacer9 = " "
spacer10 = " "
spacer11 = " "
spacer12 = " "
spacer13 = " "
spacer14 = " "
spacer15 = " "
spacer16 = " "
spacer17 = " "
spacer18 = " "
spacer19 = " "
spacer20 = " "
tsql = "SELECT COUNT(name) AS hm FROM lores WHERE realname LIKE "
tsql = %concat(@tsql,"'",%replace(%lower(%4),"'","''"),"'")
hm = %sql(Arctic,@tsql)

#IF (@hm.Item("hm") >= 1) {
tsql = ""
tsql = "SELECT * from lores where realname LIKE "
tsql = %concat(@tsql,"'",%replace(%lower(%4),"'","''"),"'")
ichk = %sql(Arctic,@tsql)
#IF (@ichk.Item("aff1") = "DEX 1" or @ichk.Item("aff2") = "DEX 1" or @ichk.Item("aff3") = "DEX 1" or @ichk.Item("aff4") = "DEX 1" or @ichk.Item("aff5") = "DEX 1") {
p2 = "D1 "+@p2
}
#IF (@ichk.Item("aff1") = "DEX 2" or @ichk.Item("aff2") = "DEX 2" or @ichk.Item("aff3") = "DEX 2" or @ichk.Item("aff4") = "DEX 2" or @ichk.Item("aff5") = "DEX 2") {
p2 = "D2 "+@p2
}
#IF (@ichk.Item("aff1") = "STR 1" or @ichk.Item("aff2") = "STR 1" or @ichk.Item("aff3") = "STR 1" or @ichk.Item("aff4") = "STR 1" or @ichk.Item("aff5") = "STR 1") {
p2 = "S1 "+@p2
}
#IF (@ichk.Item("aff1") = "STR 2" or @ichk.Item("aff2") = "STR 2" or @ichk.Item("aff3") = "STR 2" or @ichk.Item("aff4") = "STR 2" or @ichk.Item("aff5") = "STR 2") {
p2 = "S2 "+@p2
}
#IF (@ichk.Item("aff1") = "CON 1" or @ichk.Item("aff2") = "CON 1" or @ichk.Item("aff3") = "CON 1" or @ichk.Item("aff4") = "CON 1" or @ichk.Item("aff5") = "CON 1") {
p2 = "C1 "+@p2
}
#IF (@ichk.Item("aff1") = "CON 2" or @ichk.Item("aff2") = "CON 2" or @ichk.Item("aff3") = "CON 2" or @ichk.Item("aff4") = "CON 2" or @ichk.Item("aff5") = "CON 2") {
p2 = "C2 "+@p2
}
#IF (@ichk.Item("aff1") = "INT 1" or @ichk.Item("aff2") = "INT 1" or @ichk.Item("aff3") = "INT 1" or @ichk.Item("aff4") = "INT 1" or @ichk.Item("aff5") = "INT 1") {
p2 = "I1 "+@p2
}
#IF (@ichk.Item("aff1") = "INT 2" or @ichk.Item("aff2") = "INT 2" or @ichk.Item("aff3") = "INT 2" or @ichk.Item("aff4") = "INT 2" or @ichk.Item("aff5") = "INT 2") {
p2 = "I2 "+@p2
}
#IF (@ichk.Item("aff1") = "WIS 1" or @ichk.Item("aff2") = "WIS 1" or @ichk.Item("aff3") = "WIS 1" or @ichk.Item("aff4") = "WIS 1" or @ichk.Item("aff5") = "WIS 1") {
p2 = "W1 "+@p2
}
#IF (@ichk.Item("aff1") = "WIS 2" or @ichk.Item("aff2") = "WIS 2" or @ichk.Item("aff3") = "WIS 2" or @ichk.Item("aff4") = "WIS 2" or @ichk.Item("aff5") = "WIS 2") {
p2 = "W2 "+@p2
}
#IF (@ichk.Item("aff1") = "CHA 1" or @ichk.Item("aff2") = "CHA 1" or @ichk.Item("aff3") = "CHA 1" or @ichk.Item("aff4") = "CHA 1" or @ichk.Item("aff5") = "CHA 1") {
p2 = "CH1 "+@p2
}
#IF (@ichk.Item("aff1") = "CHA 2" or @ichk.Item("aff2") = "CHA 2" or @ichk.Item("aff3") = "CHA 2" or @ichk.Item("aff4") = "CHA 2" or @ichk.Item("aff5") = "CHA 2") {
p2 = "CH2 "+@p2
}
#IF (@ichk.Item("eff") =~ "INVISIBLE") {
#IF (@ichk.Item("eff") =~ "DETECT") {} {p2 = "INVIS "+@p2}
}
#IF (@ichk.Item("eff") =~ "NOCHARM") {p2 = "NOCHRM "+@p2}
#IF (@ichk.Item("eff") =~ "NOSUMMON") {p2 = "NOSUM "+@p2}
#IF (@ichk.Item("eff") =~ "SNEAK") {p2 = "SNEAK "+@p2}
#IF (@ichk.Item("eff") =~ "HIDE") {p2 = "HIDE "+@p2}
#IF (@ichk.Item("eff") =~ "DETECT_INVISIBLE") {p2 = "DI "+@p2}
#IF (@hm.Item("hm") > 1) {p2 = "[2] "+@p2}

#VAR p6 %len(@p2)
#IF (@p6 = 0) {#SUB (@spacer12+@p1)}
#IF (@p6 = 1) {#SUB (@spacer11+@p2+@p1)}
#IF (@p6 = 2) {#SUB (@spacer10+@p2+@p1)}
#IF (@p6 = 3) {#SUB (@spacer9+@p2+@p1)}
#IF (@p6 = 4) {#SUB (@spacer8+@p2+@p1)}
#IF (@p6 = 5) {#SUB (@spacer7+@p2+@p1)}
#IF (@p6 = 6) {#SUB (@spacer6+@p2+@p1)}
#IF (@p6 = 7) {#SUB (@spacer5+@p2+@p1)}
#IF (@p6 = 8) {#SUB (@spacer4+@p2+@p1)}
#IF (@p6 = 9) {#SUB (@spacer3+@p2+@p1)}
#IF (@p6 = 10) {#SUB (@spacer2+@p2+@p1)}
#IF (@p6 = 11) {#SUB (@spacer1+@p2+@p1)}
}
#IF (@hm.Item("hm") = 0) {#SUB (@spacer11+"*"+@p1)}
tsql = ""


Plus, I know Javascript real well and when I switched from JMC to cMUD I had to rewrite a lot of my scripts and some I just didn't convert over because I didn't know how to do the Zscript version and I would like to get some of those scripts running again.

Do you think that ZScript can do everything JavaScript can do? If so, then I just need to learn it better.

Thanks!!!!
Derek Conlon
Reply with quote
derekconlon
Newbie


Joined: 25 Nov 2015
Posts: 8

PostPosted: Wed Nov 25, 2015 8:41 pm   
 
I also thought of another thing I would use JScript for, creating functions (called methods sometimes, subroutines, etc)

Let's say I type group and it shows all 8 people. I want to set buttons with the info in each button, but the class is different and sometimes in different positions in the party (i.e. Position 1 = warrior, but the next group it might be a mage) so rather than have each position check for each class, I could write a function that is called for each position that sends the class name and the health, then the function processes that information.

just would make for neater code.

can Zscript do methods or functions or subroutines?
Reply with quote
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: Wed Nov 25, 2015 8:56 pm   
 
derekconlon wrote:

can Zscript do methods or functions or subroutines?


Check out #FUNCTION (which can return a value)

I assume you're familiar with triggers and aliases.
Reply with quote
derekconlon
Newbie


Joined: 25 Nov 2015
Posts: 8

PostPosted: Wed Nov 25, 2015 9:15 pm   
 
Tarn wrote:
derekconlon wrote:

can Zscript do methods or functions or subroutines?


Check out #FUNCTION (which can return a value)

I assume you're familiar with triggers and aliases.


Thank you... I feel dumb.

I think I was searching "functions" and "methods" .. not "function"

This will likely do what I want it to do.
Reply with quote
derekconlon
Newbie


Joined: 25 Nov 2015
Posts: 8

PostPosted: Wed Nov 25, 2015 9:17 pm   
 
I'm still wanting to know how to do Javascript though.
I appreciate all the ZScript options that replace things I'd be using Javascript for but it IS something cMUD is supposed to do (use javascript) and I'd like to know how.
Reply with quote
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: Wed Nov 25, 2015 10:17 pm   
 
derekconlon wrote:
I'm still wanting to know how to do Javascript though.
I appreciate all the ZScript options that replace things I'd be using Javascript for but it IS something cMUD is supposed to do (use javascript) and I'd like to know how.


As an example, I created a function named javascriptfunction, selected "JScript" as the language, and then gave it the body

a = 4;
b = 3;
c = 2;
javascriptfunction = a-b-c+2;

That last line is what returns the value of the function where CMUD can find it.

Then from the CMUD command line,
#show javascriptfunction()
returns the expected value of 1

Depending on how you want to use JavaScript, #SCRIPT and %mss may also be of interest to you.
Reply with quote
derekconlon
Newbie


Joined: 25 Nov 2015
Posts: 8

PostPosted: Thu Nov 26, 2015 12:24 am   
 
Actually, my original post was regarding #SCRIPT.

I can't figure out the syntax to get it to use Javascript. That's what this whole thread was conceived for :)

%mss is also something i've looked at and yes, it will also benefit me but I wanted to get #SCRIPT working first.

%mss also always seems to use VBScript and I can't get it to use Javascript.

and thank you for your reply, I didn't realize you had to make it say "javascriptfunction=" although i'll test the "alert();" function here as soon as I can and see if it works or not.

If cMUD can't do full blown javascript, that's ok, i just need to know that so I quit thinking about it.

Plus, is there a way to pass variables between Zscript and Javascript? or is it your triggers have to be one or the other?

I'm assuming that #SCRIPT will do that but then how do you pass the Zscript variables through #SCRIPT to the Javascript and then back.

I mean, if you could just write a quick alias that does this:

Zscript:
#VAR abc = "123"
#SCRIPT {some javascript, returnin the #VAR abc defined earlier}
#SHOW javascript variable that has the "123" value from #VAR abc earlier.

I'd be able to try to figure out the rest.

The documentation is just so minimal its hard for me to figure anything out.

Everything is assuming you want to use VBscript and it jsut says "and also does javascript" but doesn't show you how to use that!

Thank you so much!!
Derek Conlon
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Thu Nov 26, 2015 3:08 am   
 
Quote:
Right now the only thing that ZScript is lacking that I have needed recently is a "Does not match" abililty. the =~ does "match" but what about if "not match". am I just missing something?


The not operator is the exclamation point. You can test for does not match with !(string1 =~ string2).

Quote:
If the Item has "INIVISIBLE" and "DETECT_INVISIBLE" both and you want it to show "INVIS" and "DI" when doing a list at a merchant, I had to do this: (full code below)

#IF (@ichk.Item("eff") =~ "INVISIBLE") {
#IF (@ichk.Item("eff") =~ "DETECT") {} {p2 = "INVIS "+@p2}
}
#IF (@ichk.Item("eff") =~ "DETECT_INVISIBLE") {p2 = "DI "+@p2}


It looks like what you actually want here is something like this: #IF (@ichk.Item("eff") =~ "%qINVISIBLE%q"). The %q matches a word boundary, so this will match INVISIBLE, but not DETECT_INVISIBLE.

Quote:
This script also lags and I think it would run faster with Javascript (maybe it would not but I want to learn how to do it with Javascript to find out)


The first thing that jumps out at me is that you're using a ton of global variables here. If you don't need to access them outside this trigger, switching them to local variables would be recommended. Although in this case I suspect that the bottleneck is just the sql access. Maybe someone who knows more about using sql in cmud could weigh in on whether these commands automatically run in a different thread, or if threading them manually would be required?

Quote:
Actually, my original post was regarding #SCRIPT.

I can't figure out the syntax to get it to use Javascript. That's what this whole thread was conceived for :)

%mss is also something i've looked at and yes, it will also benefit me but I wanted to get #SCRIPT working first.

%mss also always seems to use VBScript and I can't get it to use Javascript.


As per the helpfiles for #script and %mss, they both accept a language parameter. Something like this:
Code:
#script {function increment(x) {return x + 1;}} "JScript"
#show %mss("increment(5);", "JScript") // prints 6


Quote:
Plus, is there a way to pass variables between Zscript and Javascript? or is it your triggers have to be one or the other?


You can access zScript variables in other languages with zvar.varname. There's no way to access variables defined locally in other languages from zScript, but you could set a zScript variable to read later, or get the return value of a function with %mss.
Reply with quote
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: Thu Nov 26, 2015 8:46 pm   
 
derekconlon wrote:

If cMUD can't do full blown javascript, that's ok, i just need to know that so I quit thinking about it.


I'm not sure what you mean by "full blown javascript". Individual functions or aliases/subs can invoke javascript and pass values back and forth.

Quote:

Plus, is there a way to pass variables between Zscript and Javascript? or is it your triggers have to be one or the other?


Both... you can pass variables back and forth, but a given piece of code is either zscript or some other scripting language (vbscript, javascript, etc.).

Quote:

I mean, if you could just write a quick alias that does this:

Zscript:
#VAR abc = "123"
#SCRIPT {some javascript, returnin the #VAR abc defined earlier}
#SHOW javascript variable that has the "123" value from #VAR abc earlier.

I'd be able to try to figure out the rest.


As Daern says, zvar. is what you're looking for to let javascript code get to cmud variables.

In my previous example,
a = 4;
b = 3;
c = 2;

javascriptfunction = a-b-c+2+zvar.hp;

(added +zvar.hp) lets you access a variable I declared to store hp. You'd need to do #VAR hp 50 or something to get it to exist, though, if you didn't already have one.


And you can pass variables into the function as arguments then get a value back as the return value of the function. I'm not sure what else you want to do.
Reply with quote
coloradoderek
Beginner


Joined: 07 Jan 2014
Posts: 18

PostPosted: Sat Nov 28, 2015 5:10 pm   
 
Wow guys, you are very appreciated.

I'm getting it to work now. However, the "alert()" function of Javascript still does not appear to work.

I copy/pasted your example and sure enough, it outputs 6 to the screen.

However, if I add "alert(x);" before the "return x+1;" it gives an error and doesn't work. That is what I meant by "full blown" javascript. I don't need the alert() function to work, its just how I was testing things. But, presuming i'm not doing something wrong, it would seem that alert() doesn't work with zscript or %mss or something. Not a big deal but if one function doesn't work, others might not as well, leading to me saying "not full blown javascript"

I'm going to play around with some things and learn to use the "zvar" as well.

Are there any help files relating to the "zvar" and other features that might exist? When I search "zvar" in the CMUD Help files It returns nothing, so how does one go about learning about this and the other features related to scripting with other languages other than zscript in cmud? Maybe I'm supposed to have Pro version before i'm able to get help with that stuff?

Any links to information relating to those features and others would be greatly appreciated.

Thank you so much! I'm sure i'll have more questions but for now I think you've taken care of me pretty well!

Oh!! I cant believe I didn't think about the ! (not) operator. I use that all day in PHP so I have no excuse why I didn't think of that. Also, I didn't know about the %q word boundary. That is very helpful also. Can you by chance tell me where that is found in the Help files also? I bet there are more % commands I can use that I don't know about.

Thank you again!!!

Derek Conlon
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Sat Nov 28, 2015 5:41 pm   
 
in #HELP #TRIGGER there is a link to the pattern matching wildcards.
you can also search for 'predefined' to get a list of native %variables
_________________
Discord: Shalimarwildcat
Reply with quote
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: Sat Nov 28, 2015 5:50 pm   
 
coloradoderek wrote:
Wow guys, you are very appreciated.

I'm getting it to work now. However, the "alert()" function of Javascript still does not appear to work.

...
Quote:

However, if I add "alert(x);" before the "return x+1;" it gives an error and doesn't work.


I see an "Object Expected" error. CMUD passes script like that into the Microsoft scripting engine. From what I can find from the internet in general, that error is common if you're not running in a browser because "Alert" is a function (method) of the active window and the script doesn't own a window if it's not being run in a web page.

(google search javascript alert not working)

If you want the script to use user interface elements, then I think the workaround would be to use JavaScript's ability to use ActiveX/COM calls to call your CMUD session directly.

Quote:

I don't need the alert() function to work, its just how I was testing things. But, presuming i'm not doing something wrong, it would seem that alert() doesn't work with zscript or %mss or something. Not a big deal but if one function doesn't work, others might not as well, leading to me saying "not full blown javascript"


Ok... does the above answer your question? This seems to be a commonly reported question for JavaScript on Windows, not just CMUD in particular. So it sounds like the short answer is that user interface elements aren't as easily available as they are to JavaScript running on a web page being displayed by MS Internet Explorer.

But there should be workarounds, for example the ActiveX functionality of MS JavaScript to use CMUD's COM capabilities.

Quote:

Are there any help files relating to the "zvar" and other features that might exist? When I search "zvar" in the CMUD Help files It returns nothing, so how does one go about learning about this and the other features related to scripting with other languages other than zscript in cmud? Maybe I'm supposed to have Pro version before i'm able to get help with that stuff?


Unfortunately some of that stuff is fairly obscure, particularly in languages other than VBscript.

When I've personally wanted to write particular functions in other languages (usually C++ or full VB) I've gone in the other direction: producing COM objects that CMUD calls rather than using alternate languages within CMUD so I'm not really all that experienced in exactly what you're doing.
Reply with quote
coloradoderek
Beginner


Joined: 07 Jan 2014
Posts: 18

PostPosted: Sat Nov 28, 2015 6:15 pm   
 
Tarn wrote:



I see an "Object Expected" error. CMUD passes script like that into the Microsoft scripting engine. From what I can find from the internet in general, that error is common if you're not running in a browser because "Alert" is a function (method) of the active window and the script doesn't own a window if it's not being run in a web page.

(google search javascript alert not working)

If you want the script to use user interface elements, then I think the workaround would be to use JavaScript's ability to use ActiveX/COM calls to call your CMUD session directly.


Makes complete sense. Thank you.

Quote:

When I've personally wanted to write particular functions in other languages (usually C++ or full VB) I've gone in the other direction: producing COM objects that CMUD calls rather than using alternate languages within CMUD so I'm not really all that experienced in exactly what you're doing.


I don't understand the COM stuff. The examples I've looked at, I just don't understand. I don't know if it is something that would benefit me or not but I'll try to look into it again. I'd love to write PHP code and just use that with cMUD with COM calls. I've never had any experience with COM though. Do you think its pretty easy to figure out? I consider myself a quick study but with your guys quick, easy answers to my questions, it would appear I'm not as good as I thought.
Reply with quote
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: Sat Nov 28, 2015 6:52 pm   
 
coloradoderek wrote:

I don't understand the COM stuff. The examples I've looked at, I just don't understand. I don't know if it is something that would benefit me or not but I'll try to look into it again. I'd love to write PHP code and just use that with cMUD with COM calls. I've never had any experience with COM though. Do you think its pretty easy to figure out? I consider myself a quick study but with your guys quick, easy answers to my questions, it would appear I'm not as good as I thought.


You may not be as slow as you feel... Look at our signup dates compared to yours ;)

COM is kind of a background technology. You don't need to fully understand what it's doing in the background to take advantage of it.

It allows easy sharing of objects and functionality between different applications and even programming languages.

In short, you can get a handle to the CMUD application object, and through that to the current session. You can then ask the session to do various things including execute scripts.

A few people were experimenting with it in Lua just last month:
http://forums.zuggsoft.com/forums/viewtopic.php?p=175520

I haven't tried it, but MS JavaScript claims to have the same capabilities:
https://msdn.microsoft.com/en-us/library/7sw4ddf8(v=vs.94).aspx

If you bang your head on it for more than half an hour or so without getting anywhere, I'll try to throw an example together. I understand COM in several languages, but haven't spent much time using it from JavaScript.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Nov 29, 2015 8:10 am   
 
Quote:
In short, you can get a handle to the CMUD application object, and through that to the current session. You can then ask the session to do various things including execute scripts.


You actually don't even need to get the handle - CMUD exposes both the application and the session to the WSH environment already, as the "cmud" and "sess" variables. You can read about all the functions this exposes here: http://www.zuggsoft.com/page.php?file=zmud/comserve.htm (replacing zMUD with CMUD as necessary). For example, if you wanted to send something to the MUD, you could use sess.SendStr("foo").

Quote:
I'd love to write PHP code and just use that with cMUD with COM calls.


CMUD supports any language that can run in the Windows Scripting Host. By default that's just VBScript and JScript cause they come with Windows, but if you install others, like ActivePHPScript, they should just appear in the language dropdown as well. There's a discussion thread about that here: http://www.zuggsoft.com/forums/viewtopic.php?t=28759
Reply with quote
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: Sun Nov 29, 2015 5:52 pm   
 
Daern wrote:
Quote:
In short, you can get a handle to the CMUD application object, and through that to the current session. You can then ask the session to do various things including execute scripts.


You actually don't even need to get the handle - CMUD exposes both the application and the session to the WSH environment already, as the "cmud" and "sess" variables. You can read about all the functions this exposes here: http://www.zuggsoft.com/page.php?file=zmud/comserve.htm (replacing zMUD with CMUD as necessary). For example, if you wanted to send something to the MUD, you could use sess.SendStr("foo").


Great, looks like I had something corrupted- I thought access to the session was supposed to be there but autocompletion wasn't working and trying to use it was generating error messages. Now that I cleaned out my example function and started fresh, it's good.

So, in Javascript, things like
sess.processcommand("#show Hello World");
are working just fine for me now.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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