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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sat Nov 11, 2006 9:44 pm   

[1.15] Creation of duplicate Variables in a disabled class
 
I decided to start using set and get alias/functions to access variables and set up these respectively.

#alias varset {#var %1 %2 _nodef {Vars}}
#variable varget {~%eval( ~%concat( "@Vars/", ~%1))}

They work great and they let me change my storage location and type without changing everywhere they are referenced.

Now for the bug. If these settings do not live inside the class Vars and you use the varset alias it will create multiple copies of the variable you set when you have the vars class disabled.

Example

varset thing1 2

Should set the variable called thing1 to the value of 2. A no brainer of course.
But if the class Vars is disabled it shouldn't do anything.

What it IS doing is creating another copy of thing1 and placing the value of 2 in it WITHIN Vars even though Vars is disabled.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Nov 13, 2006 7:48 pm   
 
To create a function you shouldn't be using the #variable command and shouldn't have ~ in your function. Simply use this:

#function varget {%eval( %concat( "@Vars/", %1))}

or, even more readable would be:

#function varget($varname) {%eval( %concat( "@Vars/", $varname))}

Or, using indirect variable access, you can do this:

#function varget {@{Vars/%1}}

or this:

#function varget($varname) {@{Vars/$varname}}

Anyway, back to your bug about setting a variable when the class is disabled...I reproduced this and have added it to the bug list.
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Nov 13, 2006 7:49 pm   
 
Btw, also keep in mind that using these functions and accessing a variable via

@varget(a)

instead of just @/Vars/a

will make your scripts slower.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Mon Nov 13, 2006 9:58 pm   
 
I kinda figgured it would make the scripts slower. But I use WAY more regular variables in my settings than I think I should. I thought this way I could change the regular variables to database vars or string lists and only have to make the change in the set and get stuff I set up here. Rather than all of my other settings.

Also, I make most of my settings through the gui as I mentioned in another thread. Yes I can read and spot errors in some stuff but I rarely actually type out a setting.

To make a function I use the gui and create a variable then put something in the value. Should I NOT be doing this?
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Nov 13, 2006 11:33 pm   
 
If you are using the GUI, then you are doing it right: Creating a variable and just putting the script in it is the way to do it. CMUD will eventually have "real" Functions which will be separated from Variables. The current way of using Variables as Functions is one of those wierd things left over from zMUD that I'll eventually improve. It's very confusing to people the way it is.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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