 |
Leyline Wanderer
Joined: 03 Feb 2007 Posts: 64
|
Posted: 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) |
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: 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 |
|
|
 |
Leyline Wanderer
Joined: 03 Feb 2007 Posts: 64
|
Posted: Thu Jan 17, 2008 4:18 pm |
Exactly.
Oh well thanks ) |
|
|
 |
MrCheviot Novice
Joined: 02 Dec 2007 Posts: 42
|
Posted: 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 |
|
|
 |
Leyline Wanderer
Joined: 03 Feb 2007 Posts: 64
|
Posted: 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.) |
|
|
 |
|
|