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
farfguy
Newbie


Joined: 17 May 2002
Posts: 4

PostPosted: Fri May 17, 2002 7:53 pm   

Duplicate vars in different classes
 
I know it's possible to create a class called "Test1" and put a variable called "Test" in it, and then create a class called "Test2" and put a variable in it also called "Test". Assuming both classes are enabled, is there any way to call a variable by the class? I.E. something like (if expanding the var):

@class.var

or

@class.@var

or something along those lines?

TIA,

Adam
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri May 17, 2002 8:37 pm   
 
Yes. You can disable the class whose variable you don't want to call and enable the one you do.
#T- Test2;#T+ Test1;@test for the Test1 variable
#T- Test1;#T+ Test2;@test for the Test2 variable

In most cases it would be better to just create different variables (@Test1 and @Test2).

LightBulb
Vague questions get vague answers
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Fri May 17, 2002 10:17 pm   
 
You can also change the current class with the #CLASS command. Example:
#CLASS test1
#SH The value of test is @test
#CLASS test2
#SH The value of test now is @test
#CLASS 0

Note: #CLASS 0 makes the root class folder the current one again.

Kjata
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat May 18, 2002 12:17 am   
 
Sorry, Kjata. Much to my surprise, it doesn't matter what the current class is or what class the script calling the variable is in.

LightBulb
Vague questions get vague answers
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sat May 18, 2002 1:11 am   
 
Hmm, that's really strange, I just tested this and it worked out fine. It still does. Here is what I used to test it:
#VAR test 1
#VAR test 2 _nodef "test1"
#VAR test 3 _nodef "test2"
#SH The value of test is @test
#CLASS test1
#SH The value of test is @test
#CLASS test2
#SH The value of test is @test
#CLASS 0

and it outputs:
The value of test is 1
The value of test is 2
The value of test is 3

Also, I can't find anything on the version history about a fix meaning that this is a bug in 6.16. But who knows, perhaps it is a bug that Zugg fixed and never documented.

Kjata
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat May 18, 2002 2:15 am   
 
Must be a bug in 6.16 then. I just cut-and-pasted the same script, and got:

The value of test is 3
The value of test is 3
The value of test is 3

LightBulb
Vague questions get vague answers
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat May 18, 2002 8:44 pm   
 
quote:

Must be a bug in 6.16 then. I just cut-and-pasted the same script, and got:

The value of test is 3
The value of test is 3
The value of test is 3

LightBulb
Vague questions get vague answers



Outside of #CLASS, there's no way to reference a variable if it happens to be preceded by an earlier copy (ie, trying to use @test in the Test2 class when there is one active in the Test1 class). This is because of the above bug, which as Kjata already knows (even if it wasn't quickly remembered) was fixed in one of the 6.2x betas (possibly one of the 6.16+ betas, but I'm almost sure it was a 6.2x).

li'l shmoe of Dragon's Gate MUD
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