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
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Jul 24, 2011 2:41 am   

Distinguishing between CMUD/CMUDPro in a script
 
Is there a way for a script to tell if it's running on CMUD or CMUDPro? I have some code that will only work on CMUDPro, and I would wrap the whole thing in #IF (%cmudtype = "cmudpro"), but I can't find a %cmudtype variable...
Reply with quote
Araadan
Wanderer


Joined: 07 Jun 2009
Posts: 65

PostPosted: Sun Jul 24, 2011 6:17 am   
 
Code:
#version

Reply with quote
orphean
Apprentice


Joined: 21 Oct 2008
Posts: 147
Location: Olympia, WA

PostPosted: Sun Jul 24, 2011 7:10 am   
 
#version doesn't indicate whether or not CMUD is Pro. Even if it did it would probably been more useful to use the function %version.

Daern, I could be wrong and if I am the fine gurus who live here will correct me but I don't believe there is a builtin way to do that. Luckily it is easy enough to create our own method of checking using a user-defined function and LUA:
Code:
<func name="cmudpro" language="Lua" id="58">
  <value>if zs.func.url == nil then
  return 0
else
  return 1
end</value>
</func>

So this defines the user function @cmudpro which will return 1 if the %url function exists and 0 otherwise. Since %url is only defined in CMUD Pro/TeSSH this should provide a method of programmaticly testing for Pro.

Quick example of use:
Code:
#if ( @cmudpro() ) {
  // CMUD Pro Bits here
}
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Jul 24, 2011 2:43 pm   
 
Araadan: #version, for me, displays CMUD Version: 3.34. Could someone on CMUDPro test this, and see if it says CMUDPro Version: 3.34? Still, it'll probably be more trouble than it's worth to have to make a trigger to capture and gag that, it would be nice if the full string was added to %version, or some other global variable...

Orphean: great idea, but it doesn't seem to work. Even on CMUD it returns 1, and print(zs.func.url) shows function: 159DB170, so it does seem like it's not nil. I tried zs.cmd.ftp too, can't think of any other CMUDPro only commands/functions offhand, but it doesn't look like it's going to work.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Jul 24, 2011 4:43 pm   
 
Not sure why it returns something in lua (quite possibly it's because the code for the function is there, but unless you've got pro, it won't activate), but in zscript, it seems to be working. Perhaps you can write a function in zscript to return true or false based on %url. You may have to actually populate it with something though (%url("http://www.google.com") for instance).

With that said, a %cmudtype wouldn't be a bad idea, but since most scripts are generally used on the specific version (pro vs non-pro), it probably isn't something that has even crossed Zugg's mind.
Reply with quote
orphean
Apprentice


Joined: 21 Oct 2008
Posts: 147
Location: Olympia, WA

PostPosted: Sun Jul 24, 2011 5:31 pm   
 
Well serves me right for not testing it in normal CMUD. I tested it by just looking for a nonsense function (ie, zs.func.banana) and it returned false. So it looks like %url and %ftp are still in the function table in normal CMUD and deactivated by other means.

Back to square one!
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sun Jul 24, 2011 5:53 pm   
 
I'll try to add something for this. Probably I'll change the result of #VERSION but also provide a function for it.

And yes, all of the functions/commands for CMUDPro are still recognized in CMUD (to avoid getting syntax errors for unknown function), but they point to completely empty code blocks. CMUDPro is created via conditional compilation statements in Delphi, so the functions are still there, but they just don't have any code in the regular CMUD.
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Mon Jul 25, 2011 11:15 pm   
 
Is the package directory for CMUDPro labeled as CMUDPro, or just CMUD like the normal install?
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
Fizban1216
Apprentice


Joined: 03 Feb 2007
Posts: 170

PostPosted: Tue Jul 26, 2011 12:02 am   
 
Daern wrote:
Araadan: #version, for me, displays CMUD Version: 3.34. Could someone on CMUDPro test this, and see if it says CMUDPro Version: 3.34?


It doesn't., I get "CMUD Version: 3.34" on cMUDPro

Fizgar wrote:
Is the package directory for CMUDPro labeled as CMUDPro, or just CMUD like the normal install?


CMUD like the normal install.
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