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
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Wed Nov 28, 2007 4:05 pm   

[2.13 Pro] Problems with default values
 
I was noticing that some of my variables weren't getting reset to their default values, usually an empty string or a 0, when I loaded the package or when I used #RESET or connected to the MUD. I tried to re-create this and found another related problem: my variable was initialized with the default value rather than the value I specified.

1. Open CMUD.
2. ESC to get to untitled session.
3. Paste this script into the command line:
Code:
#MODULE "Tester"
#CLASS "A"
#VAR flags "test" "default"
#CLASS 0
#MODULE 0

4. #SHOW @flags (expected result = test, result I got = default)
5. flags = test (force the value to non-default)
6. #RESET
7. #SHOW @flags (expected result = default, result I got = test)
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Nov 28, 2007 6:14 pm   
 
OK, that's a really weird one, but potentially serious. Not sure how it is getting the default value confused, but I've added it to the bug list. Good catch!
Reply with quote
Zugg
MASTER


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

PostPosted: Wed Nov 28, 2007 10:50 pm   
 
Ahh, OK, I see the problems here:

(1) When creating a *new* Module, the module sends an OnLoad event to the message queue. This gets processed after your script is done, and the OnLoad for the module resets the variables in the module to their defaults. Not sure if I can fix this or not. Since you are creating a new module, you kind of expect it to properly initialize itself, don't you?

(2) The #RESET command has a bug and isn't looping through all packages/modules. It is only resetting the current module of the current package. If you use "#RESET Tester" or "#RESET A" or "#RESET flags" then it works properly. This is fixed for v2.14.

Quote:
I was noticing that some of my variables weren't getting reset to their default values, usually an empty string or a 0, when I loaded the package

That shouldn't be happening in v2.13. It was a bug in the previous beta versions. So if you are still getting this problem, please let me know. But it's not related to the problems you listed above. When a module is created by loading a package, all of the variables in that module should get reset by the OnLoad event. It's only when you use the File/ViewPackage menu option in the settings editor that the variables don't get reset (because it doesn't call OnLoad).
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Thu Nov 29, 2007 12:30 pm   
 
My personal feeling is that OnLoad shouldn't reset the variables when creating a new module. I only expect variables to be reset when I explicitly reset them, when I connect to the MUD (maybe), or when I load my profile. I understand it may be difficult to tell the difference, and at least knowing what's going on will help me figure out a few things. (This wasn't the part of the problem I was worried about, anyway. Heh.)

Thanks for fixing the #RESET command!
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