 |
brrant Beginner
Joined: 19 Nov 2008 Posts: 14
|
Posted: Wed Nov 19, 2008 1:33 am
Question on incorporating Perl scripts. |
I'm trying to write and use perl as the scripting language. I'm using cmud and have activestate installed. I can execute perl scripts outside of cmud from the command line as well as from within ultraedit. This leads me to believe that I have it installed correctly.
When I'm within an alias or what have you in Cmud, in the upper right hand corner is a pull down for scripting language. zscript is the default, but perlscript shows up as well.
When I have zscript selected, I can write triggers, use functions (#SH, #WINDOW, #TR+-, etc.) If I include any perl language, the trigger/alias what have you, generates an error and states that it could not be compiled.
If I select perlscript, it compiles, but I don't have any method for interacting with the mud because all of the zscript functions are disabled.
It's stated that languages can be mixed in the promotional description: "Works with any other Windows scripting language. Scripting languages can be freely mixed, even within the same window. Built-in syntax highlighting for Lua, VBScript, JavaScript, Perl, Python, Ruby. "
So I assume I am just doing something wrong. Can anyone shed some light here?
Thanks |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Nov 19, 2008 4:04 am |
The API for WSH languages hasn't been updated in a long while - the interface is, if I remember rightly, limited to a table zvar that'll let you retrieve and change the values of zScript variables. You can use those to make other things happen with expression triggers if you want.
Obviously you can't incorporate Perl code into something that's got zScript as its script, so that's not going to compile. |
|
|
 |
brrant Beginner
Joined: 19 Nov 2008 Posts: 14
|
Posted: Wed Nov 19, 2008 5:18 am |
I appreciate the response, however it doesn't convey much meaning to me.
If the description of the program is that it can mix script languages in a single window, doesn't that imply that I could use zscript and perlscript together? (If I can't, how do I get data in and out of my perl scripts?)
I did use zmud for several years and did enough automation to attract inquiries from those managing the mud I played, but I have never attempted perl until now. I'm sure it's entirely possible (even likely) that I'm overlooking something profound.
If I understand your response correctly, it sounds like I can't use perlscript for much and absolutely can't mix scripting languages in a single window as the product description states.
I'm hoping that I'm just taking the wrong approach to the entire business.
Does anyone else have something to contribute?
Best regards. |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Nov 19, 2008 5:25 am |
The "single window" language is misleading you in this case, and could probably use revision. What it means is that different items within each window object can each have separate scripting languages. You can see the window object in the Package Editor's treeview - if you press Esc after CMUD loads and click the settings button, there'll be a window object there called "untitled". Each thing you create inside this window (trigger, event handler, alias, etc) can have its own script language.
You're interpreting it as meaning that you can use more than one script language within a single trigger (or whatever), which isn't the case. It's supposed to be saying that each item's script language is totally independent from any other item's.
You're right that perlscript is of limited use because, like I say, the API hasn't been updated in a long while. |
|
|
 |
brrant Beginner
Joined: 19 Nov 2008 Posts: 14
|
Posted: Wed Nov 19, 2008 5:45 am |
That's dissapointing, but thank you for the reply.
Bummer.
I must learn perl and as a semi-reformed mud addict, I thought this would be a fun way to approach it. (As well as offer me the excuse to play again. ;)
If there are limitations or I'm just not implementing things correctly, I'm happy to be instructed. As my goal is to learn and use perl, I don't feel I've wasted any time, but if I were a new purchaser on the basis of that description I would be very frustrated.
I'm not slamming zmud/cmud. Even though I've lost my license info, I bought zmud and considered it a bargain. |
|
|
 |
Tech GURU

Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Wed Nov 19, 2008 6:01 am |
I understand what you mean and if we can one of us gurus will make the change or recommend some verbiage to Zugg.
There is on when where you can mix multiple scripts with is single object (trigger alias etc) and that is with Lua. CMUD now has native lua support, full access to the zScript API and can be interspersed with zScript with the #LUA command. You can even run Lua from the command line. |
|
_________________ Asati di tempari! |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Nov 19, 2008 4:38 pm |
The other way to mix multiple languages into the same script is with the #MSS command. From a zScript script, you can do:
Code: |
#MSS "perlscript" {perl code here} |
There is also an %mss function that allows you to call a function written in another language. As Fang mentioned, the comment about being able to mix multiple languages means that each of your scripts (aliases, triggers, etc) can be written in a different language. All other clients that support multiple languages can only support a single language at one time (so you could have VBScript, for example, but not VBScript *and* Perlscript in different scripts). It's normally a restriction to the Microsoft Scripting Host that only one scripting language can be active within an application at one time. But CMUD gets around that with it's own active scripting host to allow each script to be in any language that you want.
The LUA interface for CMUD is much more extensive that the interface for Active Scripting languages. Active Scripting languages can only access CMUD via the CMUD COM API. If you select the Support/zMUD Support menu at the top of this site, you should find an article describing the COM API for zMUD. The API is the same for CMUD but you replace anything that says "zmud" with "cmud".
So, it is very possible to use ActivePerl for full scripting in CMUD, but it requires more knowledge than a beginner might have and certainly isn't a good idea for someone just learning Perl. But this is true of any scripting software. Obviously Perl doesn't have any "built-in" commands to access CMUD. The only way to interface between a scripting language and other programs is using a COM-based API interface. You create an application object for the program you are trying to work with, and then call properties and methods of that object.
Anyway, I'm just saying that CMUD is not special in this regard. Any MUD client or any other software that supported Perl would require the same sort of COM-based API interface. Only LUA has special ways to make external stuff like CMUD look like it was "built-in". LUA is very extensible in this way, which is why it has become popular. I'm sure someone could write a Perl Library that make the COM interface for CMUD easier to use. But honestly, nobody really uses Perl as a MUD language because Perl just wasn't designed for that and any Microsoft Scripting language (like ActivePerl) is going to be slower than just using the native language supported by the client software (zScript or Lua in the case of CMUD). |
|
|
 |
brrant Beginner
Joined: 19 Nov 2008 Posts: 14
|
Posted: Thu Nov 20, 2008 1:09 am |
Zugg, thanks for the thorough reply. If Lua is as capable as Perl in the real world, I'll consider learning it. As you are probably pretty thoroughly familiar with the subject, could you recommend a good book or two on Lua? I'm kind of surprised that O'Reilly doesn't have a book on the language.
Thanks
P.S. Yes I have found the guide in the tutorials section and am going through it, but I might like something more in depth. |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Nov 20, 2008 1:38 am |
There's a book called Programming in Lua, the first edition of which is available on the web for free on lua.org. It's for an earlier version of Lua 5, though, so some stuff's out of date - the only thing you'll really encounter that's different is the way functions with multiple arguments are handled, which is explained on various wikis and whatnot around the web.
|
|
|
 |
|
|
|
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
|
|