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
oxseyn
Wanderer


Joined: 26 Nov 2011
Posts: 71
Location: Colorado Springs

PostPosted: Sat Mar 24, 2012 2:29 pm   

Nested Items & Scoping
 
So, from what I can tell the root package is named via whatever I've labeled the session.
In my case, the name of the session is "Nannymud."
Nested inside that I have three elements: two windows & a map. The windows named after my characters, we'll just call them "Char1" and "Char2." The map is named "nannymud."
Next under the window "char1" I have a class titled "init."
Under that class "init" I have stuff that's performed when connecting to the mud. There is a class "autolog" with a trigger that responds to "What is your name:" with the text "char1."

I'm trying to understand the scoping. I was hoping proper scoping existed, so that there would be a way to refer to something like:
Nannymud.Char1.Init.Autolog.NameTrigger

but instead it appears that each window/module has just a global scope and anything defined regardless of where it is nested is inserted into that global scope. Is that correct?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Mar 24, 2012 4:47 pm   
 
Right. There are some rules and quirks that set up scope-like conditions, though. For example, with the exception of variables anything found inside a window is not available to anything outside that window. Similarly, if a package is not part of a window's visible-packages list (see the window's Advanced tab, or use the %packages() function) then it can't see stuff in that package. For modules, there is also a visibility property that determines if they are visible to everything (global), only to stuff in the same package (local), or only to stuff not in the same package (external).

Commands like #T+ and #T- also take a setting-type argument to limit what they will operate on. "#T+ char1 class" will only look for a class named char1, and if there was a variable or alias name this as well then it wouldn't be enabled.

To specify the path to the setting you want, you use this format: //module/class/class/.../setting. module is the name of the window or module the setting is found. class is all the classes and subclasses along the way to the setting. setting is the name of the setting being referenced (see the More/Less Info panel to set the setting name).
_________________
EDIT: I didn't like my old signature
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