|
jed Adept
Joined: 18 Dec 2005 Posts: 246
|
Posted: Mon Mar 05, 2007 2:17 am
[1.25] Variables not loading correctly |
I have noticed in a few different scripts that it seems as though variables that I set in a script, don't always get set when I try to set them. A for instance is:
Code: |
#forall @roomlist {#show this is i %i;#var tmprmfora a%i;#var tmprmforb b%i;#show this is the matched room %db(@dmpaths,@tmprmfora);#show this is b %db(@dmexpandedpaths,@tmprmforb);#IF (%db(@dmexpandedpaths,@tmprmforb)=@oldpath3) {
#show This room matches %i llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
#var destroom %db(@dmpaths,@tmprmfora)
#show destroom @destroom
} {#show no go}} |
The destroom the last time I ran this, the outcome of this indicated that "This is the matched room " expression evaluated to 1700, sooo the destroom var should have been set to 1700 however the last time i ran the script it was set at 1625. I'm thinking this was the outcome of the last time i ran the script. This time, the destroom variable didn't get written at all...
As I mentioned, I've seen this elsewhere, and it seem if a person puts in a wait command for a second or two, it writes correctly.
This being said, I've gotten my cpu rather hot in the recent past, so I'm wondering if it's not screwing up somehow and maybe missing some steps. I've got a new machine on the way and it should be running within a week or so, it'll be interesting to see if that cures this problem. OOR as with my last post maybe I forgot a } somewhere :)
Thanks for reading,
Jed |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Mon Mar 05, 2007 7:43 am |
Well, I took at look at it and thought I would pretty it up for you so that it was easier to read.
Code: |
#forall @roomlist
{
#show this is i %i
#var tmprmfora a%i
#var tmprmforb b%i
#show this is the matched room %db(@dmpaths,@tmprmfora)
#show this is b %db(@dmexpandedpaths,@tmprmforb)
#IF (%db(@dmexpandedpaths,@tmprmforb)=@oldpath3)
{
#show This room matches %i llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
#var destroom %db(@dmpaths,@tmprmfora)
#show destroom @destroom
}
{
#show no go
}
} |
There aren't any missing braces this time around, but I would like to point out that you don't always actually SET destroom to anything. When the if doesn't pan out you just display "no go". If you get "no go" you would indeed still have the old value in destroom.
To avoid this confusion you could set destroom to %null above the forall.
Code: |
#var destroom {} {} |
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
jed Adept
Joined: 18 Dec 2005 Posts: 246
|
Posted: Tue Mar 06, 2007 11:59 pm |
hmm. I normally initialize variables by using
Is this the correct way, or should I be initializing them by using the
Code: |
#var destroom {} {} |
that you indicate
|
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Wed Mar 07, 2007 12:08 am |
Both work, the difference between mine and yours is that when you restart zmud/cmud the variable will be set to null regardless of what was in it when you unloaded the program.
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
|
|
|
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
|
|