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
Asilient_1
Apprentice


Joined: 26 Apr 2007
Posts: 113

PostPosted: Sat Apr 28, 2007 3:06 pm   

Questions about Modules.
 
Okay. So I've started playing around with modules, the help file isn't very, er, helpful in what limits there are to modules, so I've got a question.

Is it possible to refer to variables in other modules that are currently loaded, or do classes have to be used for that?

I'll probably come up with more as I go along.

Thanks for any help.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Apr 28, 2007 4:30 pm   
 
Modules = Windows, except that Modules have the ability to share their settings with other modules and windows. Windows don't share anything, so a Module can't see the variables and stuff that are in the Windows.

It's an ability, in that there are several options that change the visibility of that module. For instance, you can keep it local to the current package, you can make it invisible to the current package, or you can make it visible to every package.
_________________
EDIT: I didn't like my old signature
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Apr 30, 2007 5:48 pm   
 
To refer to a variable in a specific module, you can use the syntax:

#SHOW @//modulename/varname
Reply with quote
Asilient_1
Apprentice


Joined: 26 Apr 2007
Posts: 113

PostPosted: Tue May 01, 2007 10:48 am   
 
So to refer to a variable in a different module in an if statment would work like...

#IF (@//modulename/varname AND @thisvariable AND @//differentmodule/differentvariable) {say hi}

That's how I understand it?
Reply with quote
Zugg
MASTER


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

PostPosted: Tue May 01, 2007 5:04 pm   
 
Yep. Just keep in mind that this bypasses normal scoping rules, and you might end up with scripts that are hard to support if you start regularly accessing variables in other non-global modules. So it should only be used when absolutely necessary. Normally you'd just want to make your module Global.
Reply with quote
Asilient_1
Apprentice


Joined: 26 Apr 2007
Posts: 113

PostPosted: Tue May 01, 2007 8:09 pm   
 
Got it. Thanks for the help.
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