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


Joined: 22 Sep 2003
Posts: 53
Location: United Kingdom

PostPosted: Wed Jul 19, 2006 6:48 pm   

[1.03] Problem with access to variables in the root and clas
 
There seems to be a problem being able to access the current variable in a class when there is another variable of the same name in the root. For example, variable t1 created in a calss Test Class 1 and also in the root.

1. Start Cmud from scratch with a blank settings file.
2. Create A Class called "Test class"
3. Create an aliase is Test Class called test1: #echo |@t1|
4. Create an aliase in Test Class called Test2: #echo |@/t1|
5. Create an aliase in Test Class called Test3: #echo |@./t1|
6. Create a variable in Test Class called t1 containing "Class"
7. Create a variable in the root called t1 containing "Root"
8. Run test1, should see "|Class|" displayed, but you see "|Root|" - ERROR
9. Run test2, should see "|Root|" displayed and you do see "|Root|" - Correct
10. Run test3, should see "|Class|" displayed but you see "|Root|" - ERROR
11. Delete the variable t1 in the root
12. Run test1, should see "|Class|" displayed, but you see "||" - ERROR
13. Run test2, should see "||" displayed and you do see "||" - Correct
14. Run test3, should see "|Class|" displayed but you see "||" - ERROR
15. Enable the variable t1 in the root - t1 is no longer greyed out
16. Run test1, should see "|Class|" displayed, you see "|Class|" - Correct
17. Run test2, should see "||" displayed and you do see "||" - Correct
18. Run test3, should see "|Class|" displayed but you see "||" - ERROR

Note - it seem that depending on how you create the variables in the class (order and method) some of the above results can vary. using the settings editor to drag variables from the class to the root and back again for example.

Or have I missunderstood how accessing variables should work?
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Jul 20, 2006 2:05 am   
 
Sounds like some bugs to me. I'll use this post to test those things myself. It's possible that the problem is being caused by the settings editor. I have a test script that I run to test these things that work. Here is the script that works:
Code:
; Class testing
;
Class = 0
#class 0
#unvar a
#unvar b
#delclass sub1
#delclass sub2
#var a "Top Level"
#class sub1
; referencing @a in subclass should change global variable
#var a "Test sub"
#class 0
t Class 1 "Test sub" @a
; set it back
#var a "Top Level"
#class sub1
; now, ./a creates a new reference within current class
#var ./a "sub1"
#var ./b "sub1b"
#class 0
#class "sub2"
#var ./a "sub2"
#var ./b "sub2b"
#class 0
t Class 2 "Top Level" @a
#class sub1
t Class 3 "sub1" @a
t Class 4 "sub1" @./a
t Class 5 "Top Level" @/a
t Class 6 "Top Level" @../a
#class 0
; now test disabling classes
#class "sub1" 0
t Class 7 "sub2b" @b
#class "sub1" 1
#class "sub2" 0
t Class 8 "sub1b" @b

So this is testing similar stuff, but is doing it all via the command line. So somehow creating the classes and variables with the command line is different than the settings editor.

Oh, the "t" alias that is used for testing does this:
Code:
#ALIAS t {#ADD %1 1;#SHOW {%1 - %2 : %3 : %4 :};#IF ({%3} = {%4}) {#COLOR green;#ADD %1 -1} {#COLOR high,red}}

and is used to automatically flag errors in red.
Reply with quote
jat63
Wanderer


Joined: 22 Sep 2003
Posts: 53
Location: United Kingdom

PostPosted: Thu Jul 20, 2006 2:17 pm   
 
Thanks, I think the main difference between your tests (which work for me) and mine is the use of #class to set the context when you are referencing the variables.

I would have expected that within an alias that the class it was in would have been automatcally inherited? Or do I need to to put


Code:
#class

alias stuff

#class 0


within the text of each aliase?
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Jul 20, 2006 5:17 pm   
 
No, actually that is a property of the class itself. If you click on a class in the settings editor, you should see an option like "Set this class as default..." or something like that. This tells CMUD to set the class as the default (like using the #class command) whenever executing aliases or triggers within that class.
Reply with quote
jat63
Wanderer


Joined: 22 Sep 2003
Posts: 53
Location: United Kingdom

PostPosted: Thu Jul 20, 2006 6:13 pm   
 
I think I am getting out of my depth here! I have tried a few more things and I not sure that the "set this class as default" is making any difference.

I have created a class called test with the following two aliase inside (this is the text visable inside the setting editor window):

test1
Code:
#class test
#echo Test 1 inside |@a| |@/a| |@./a|
#class 0
#echo Test 1 Outside |@a| |@/a| |@./a|


test2
Code:
#echo Test 2 |@a| |@/a| |@./a|


And created a variable a in the class with "Class" and a in the root with "root"

Running test1 I get

Test 1 inside |Class| |Root| |Class|
Test 1 Outside |Root| |Root| |Root|

Running test2 I get

Test 2 |Root| |Root| |Root|

Both results are the same with the setting checked or not checked.
Reply with quote
Zugg
MASTER


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

PostPosted: Thu Jul 20, 2006 10:37 pm   
 
It's very possible that the "set this class as default" option isn't working correctly. Don't worry...what you have found is definitely some sort of bug (or bugs) and it's on my list to look into.
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Thu Jul 20, 2006 11:33 pm   
 
I have gotten a lot of things to work via command line that creation in the gui editor side just doesnt work.

I.E Data record variables it just crashes. Others dont save properly and have to be resaved to compile code correctly but its better :)

Tweak Tweak
_________________
Confucious say "Bugs in Programs need Hammer"
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Fri Jul 21, 2006 8:03 pm   
 
I have problems trying to set default values on imported variables, CMUD crashes to the bug reporter.
_________________
Taz :)
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