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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
zlaker
Newbie


Joined: 01 Apr 2003
Posts: 9

PostPosted: Thu Apr 03, 2003 8:49 am   

Scoping in zMUD classes
 
Are you even allowed to name two variables the same thing if they're in different classes?

If so, if I create two variables by the same name, for an example.. let's call them both foo. One is in a class called Class1, the other is in a class called Class2.

In Class2, can I access Class1::foo, and vice versa? If so, how.

Related question. If I have Class2 as a subclass of Class1, if I access foo (they both have a foo) which do I get? I'd assume Class2's foo, but is that garunteed?

Do the same rules hold for trigger binding? Like, if I have two triggers with ID of 'foo', can I turn them off and on with #T+ and #T- independant of each other?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Apr 03, 2003 12:31 pm   
 
What you want can be done using the class character (defaults to /). The syntaxes for it are:
./setting refers to setting in None class.
../setting refers to setting in parent class, only really usable when a class is the default class through #CLASS or the 'Set as default' class option.
class/setting refers to a setting in class relative to current default.

These can be combined like ./class/setting or /class/class/../class/setting.

The character can be used both when creating and when accessing settings
#VAR ./class1/foo abc
#VAR foo def {_nodef} {class2}
#SHOW @class1/foo
#ECHO @class2/foo

The same would work with #T+ and #T-, and anyother command that references or create settings.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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