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


Joined: 03 Feb 2007
Posts: 64

PostPosted: Thu Jan 17, 2008 5:11 am   

Scope only variable
 
Is there a way to use scoped variables,
ie: only during the context of this trigger exectuion,
or only during the scope of an alias,

Or do I have to make variables,
then #unvar them?

(I just wanted to avoid destroying other variables when I have to do multiple layered calculations)
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Jan 17, 2008 5:26 am   
 
Are you talking about local variables? There isn't a way to have local variables in zMUD, but there are local variables in CMUD. Great thing - it's a variable only for the script. :P

Charneus
Reply with quote
Leyline
Wanderer


Joined: 03 Feb 2007
Posts: 64

PostPosted: Thu Jan 17, 2008 4:18 pm   
 
Exactly.

Oh well thanks )
Reply with quote
MrCheviot
Novice


Joined: 02 Dec 2007
Posts: 42

PostPosted: Thu Jan 17, 2008 5:26 pm   
 
Keeping track of variables in ZMUD can become a bit messy if you pay no attention to such things and have several scripts or classes running.. especially if you're using things other people may have written.

In practice, awhile back I started making a 'var' subclass in each of my toplevel class folders, and then when I use #VAR I follow up with {_nodef} "class|vars" to explicitly place them there. It was actually in response to scripts I had imported with open class tags thereby causing newly created variables to be put into those classes (often resulting in duplicate variables which is not good), but I've since adopted it as a good programming practice in ZMUD. It is a tad cumbersome and doesn't approach the ease of using local variables in CMUD, however it keeps things organized, greatly reduces risk of dupe vars, and you can always write routines to #unvar unwanted things when you're done using them.


-MrC
Reply with quote
Leyline
Wanderer


Joined: 03 Feb 2007
Posts: 64

PostPosted: Thu Jan 17, 2008 5:36 pm   
 
My next task is to explore,
what happens when you DO have dupe variables....

say varTemp in classA
and varTemp in classB

I guess it searches root, then top down the class lists and uses the first one found,
(root being the default class you are in, or the actual root.)
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