 |
DanteX Apprentice
Joined: 13 Aug 2007 Posts: 166
|
Posted: Thu Nov 05, 2009 8:01 am
[3.21] Database variables automatically saved / sorted in the wrong order |
Hi all
I have a database variable in which the elements must be in a certain order for a script ported from zmud to work properly. The basis is that a database variable must be as follows:
sustenance=2|night vision=0|pass door=0|ectoplasmic form=2|sense anger=2|detect evil=2|detect good=2|detect invis=2|detect hidden=2|detect magic=2|fly=2|levitation=0|sanctuary=0|biofeedback=2|true seeing=0|accelerate=0|haste=0|champions strength=0|wraith form=2|aid=0|self harmony=0|party harmony=0|call upon faith=2|pure faith=2|prayer of fortune=0|calculation=0|enlightenment=0|revelation=0|intellect fortress=0|awakening=0|perception=0|godly embrace=0|energy ball=0|harden body=0|power of faith=0|mystic might=0|magical rush=0|divine swiftness=0|adrenaline control=0|rally=2|energy containment=0|giant strength=0|enhanced strength=0|lightspeed=0|frenzy=0|combat mind=2|bless=0|divine faith=2|wolf spirits=0|channel energy=0|absorb=0|antimagic shell=0|underwater breathing=0|protection good=1|inertial barrier=0|holy aura=0|indestructible aura=0|grey aura=0|spirit shield=0|protection evil=2|party shield=0|totem guidance=2|totem force=2|gaias revenge=0|test of faith=2|huntmaster=2|magic circle=0|compression=0|avoidance=0|displacement=0|mental barrier=0|flesh armor=0|darkness=0|stone skin=0|barkskin=0|armor=0|blur=0|shield=0|thought shield=0|line of protection=0|globe of invulnerability=0|heat shield=0|willpower=2|warmth=0|vaccinate=0|acidproof=0|energy shield=0|shockproof=0|holy mirror=0|toxic resistance=0|power projection=2|air focus=2|water focus=2|fire focus=2|earth focus=2|elemental ward=2
But no matter what I do in CMUD, the variable always ends up being
air focus=2|shockproof=0|inertial barrier=0|detect invis=2|giant strength=0|water focus=2|divine swiftness=0|enhanced strength=0|elemental ward=2|wolf spirits=0|mental barrier=0|indestructible aura=0|sense anger=2|godly embrace=0|mystic might=0|compression=0|magic circle=0|earth focus=2|underwater breathing=0|barkskin=0|blur=0|acidproof=0|toxic resistance=0|displacement=0|sanctuary=0|true seeing=0|thought shield=0|combat mind=2|levitation=0|grey aura=0|armor=0|detect good=2|channel energy=0|rally=2|self harmony=0|party shield=0|avoidance=0|fly=2|huntmaster=2|night vision=0|flesh armor=0|warmth=0|protection evil=2|totem force=2|perception=0|shield=0|detect magic=2|darkness=0|heat shield=0|intellect fortress=0|frenzy=0|harden body=0|detect hidden=2|energy ball=0|holy aura=0|pure faith=2|accelerate=0|call upon faith=2|energy containment=0|power projection=2|pass door=0|divine faith=2|party harmony=0|vaccinate=0|calculation=0|gaias revenge=0|adrenaline control=0|spirit shield=0|haste=0|awakening=0|holy mirror=0|sustenance=2|revelation=0|bless=0|stone skin=0|biofeedback=2|globe of invulnerability=0|test of faith=2|wraith form=2|energy shield=0|line of protection=0|antimagic shell=0|willpower=2|fire focus=2|ectoplasmic form=2|detect evil=2|lightspeed=0|totem guidance=2|prayer of fortune=0|aid=0|power of faith=0|magical rush=0|protection good=1|champions strength=0|enlightenment=0|absorb=0
I have tried to manually change the "type" setting of variable it is, setting it to a "string list" e.g., in order to paste the correct order, but no matter what I do, it always ends up that wrong order. This is in a session that is newly created and it's not the one ported from zmud.
Is this a bug or are we not supposed to be able to store database variables / keys in the order we want?
With regards
//DanteX |
|
|
 |
DanteX Apprentice
Joined: 13 Aug 2007 Posts: 166
|
Posted: Thu Nov 05, 2009 8:11 am |
If a create a new session and do the following
var={sustenance=2|night vision=0|pass door=0|ectoplasmic form=2|sense anger=2|detect evil=2|detect good=2|detect invis=2|detect hidden=2|detect magic=2|fly=2|levitation=0|sanctuary=0|biofeedback=2|true seeing=0|accelerate=0|haste=0|champions strength=0|wraith form=2|aid=0|self harmony=0|party harmony=0|call upon faith=2|pure faith=2|prayer of fortune=0|calculation=0|enlightenment=0|revelation=0|intellect fortress=0|awakening=0|perception=0|godly embrace=0|energy ball=0|harden body=0|power of faith=0|mystic might=0|magical rush=0|divine swiftness=0|adrenaline control=0|rally=2|energy containment=0|giant strength=0|enhanced strength=0|lightspeed=0|frenzy=0|combat mind=2|bless=0|divine faith=2|wolf spirits=0|channel energy=0|absorb=0|antimagic shell=0|underwater breathing=0|protection good=1|inertial barrier=0|holy aura=0|indestructible aura=0|grey aura=0|spirit shield=0|protection evil=2|party shield=0|totem guidance=2|totem force=2|gaias revenge=0|test of faith=2|huntmaster=2|magic circle=0|compression=0|avoidance=0|displacement=0|mental barrier=0|flesh armor=0|darkness=0|stone skin=0|barkskin=0|armor=0|blur=0|shield=0|thought shield=0|line of protection=0|globe of invulnerability=0|heat shield=0|willpower=2|warmth=0|vaccinate=0|acidproof=0|energy shield=0|shockproof=0|holy mirror=0|toxic resistance=0|power projection=2|air focus=2|water focus=2|fire focus=2|earth focus=2|elemental ward=2}
then #SHOW @var, it will show in the right order
If I then go into the settings editor, it appears to be stored as a string list. Changing it to a database, it changes the order. If I then #SHOW @var again, it's in the wrong order. |
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Thu Nov 05, 2009 2:09 pm |
Yeah. It's always done that, and I'm not sure there's much that can be done about it.
My database actually has stored it in proper order, but I think that's because I've used the #ADDKEY command to add them instead of the #VAR x a=b.
Try that instead?
Charneus |
|
|
 |
DanteX Apprentice
Joined: 13 Aug 2007 Posts: 166
|
Posted: Thu Nov 05, 2009 2:19 pm |
Charneus: They are added with #ADDKEY originall(inside the... it's Ninjas spellup script (made for zmud originally and I'm working on converting it...)
I'll try going through it and add it all manually, see if it'll work then
//DanteX |
|
|
 |
DanteX Apprentice
Joined: 13 Aug 2007 Posts: 166
|
Posted: Thu Nov 05, 2009 2:36 pm |
I just made the following alias and ran it:
<alias name="SpellupTestAlias" id="7783">
<value>#ADDKEY SpellupAllSpellsOnMe "sustenance" 2
#ADDKEY SpellupAllSpellsOnMe "night vision" 0
#ADDKEY SpellupAllSpellsOnMe "pass door" 0
#ADDKEY SpellupAllSpellsOnMe "ectoplasmic form" 2
#ADDKEY SpellupAllSpellsOnMe "sense anger" 2
#ADDKEY SpellupAllSpellsOnMe "detect evil" 2
#ADDKEY SpellupAllSpellsOnMe "detect good" 2
#ADDKEY SpellupAllSpellsOnMe "detect invis" 2
#ADDKEY SpellupAllSpellsOnMe "detect hidden" 2
#ADDKEY SpellupAllSpellsOnMe "detect magic" 2
#ADDKEY SpellupAllSpellsOnMe "fly" 2
#ADDKEY SpellupAllSpellsOnMe "levitation" 0
#ADDKEY SpellupAllSpellsOnMe "sanctuary" 0
#ADDKEY SpellupAllSpellsOnMe "biofeedback" 2
#ADDKEY SpellupAllSpellsOnMe "true seeing" 0
#ADDKEY SpellupAllSpellsOnMe "accelerate" 0
#ADDKEY SpellupAllSpellsOnMe "haste" 0
#ADDKEY SpellupAllSpellsOnMe "champions strength" 0
#ADDKEY SpellupAllSpellsOnMe "wraith form" 2
#ADDKEY SpellupAllSpellsOnMe "aid" 0
#ADDKEY SpellupAllSpellsOnMe "self harmony" 0
#ADDKEY SpellupAllSpellsOnMe "party harmony" 0
#ADDKEY SpellupAllSpellsOnMe "call upon faith" 2
#ADDKEY SpellupAllSpellsOnMe "pure faith" 2
#ADDKEY SpellupAllSpellsOnMe "prayer of fortune" 0
#ADDKEY SpellupAllSpellsOnMe "calculation" 0
#ADDKEY SpellupAllSpellsOnMe "enlightenment" 0
#ADDKEY SpellupAllSpellsOnMe "revelation" 0
#ADDKEY SpellupAllSpellsOnMe "intellect fortress" 0
#ADDKEY SpellupAllSpellsOnMe "awakening" 0
#ADDKEY SpellupAllSpellsOnMe "perception" 0
#ADDKEY SpellupAllSpellsOnMe "godly embrace" 0
#ADDKEY SpellupAllSpellsOnMe "energy ball" 0
#ADDKEY SpellupAllSpellsOnMe "harden body" 0
#ADDKEY SpellupAllSpellsOnMe "power of faith" 0
#ADDKEY SpellupAllSpellsOnMe "mystic might" 0
#ADDKEY SpellupAllSpellsOnMe "magical rush" 0
#ADDKEY SpellupAllSpellsOnMe "divine swiftness" 0
#ADDKEY SpellupAllSpellsOnMe "adrenaline control" 0
#ADDKEY SpellupAllSpellsOnMe "rally" 2
#ADDKEY SpellupAllSpellsOnMe "energy containment" 0
#ADDKEY SpellupAllSpellsOnMe "giant strength" 0
#ADDKEY SpellupAllSpellsOnMe "enhanced strength" 0
#ADDKEY SpellupAllSpellsOnMe "lightspeed" 0
#ADDKEY SpellupAllSpellsOnMe "frenzy" 0
#ADDKEY SpellupAllSpellsOnMe "combat mind" 2
#ADDKEY SpellupAllSpellsOnMe "bless" 0
#ADDKEY SpellupAllSpellsOnMe "divine faith" 2
#ADDKEY SpellupAllSpellsOnMe "wolf spirits" 0
#ADDKEY SpellupAllSpellsOnMe "channel energy" 0
#ADDKEY SpellupAllSpellsOnMe "absorb" 0
#ADDKEY SpellupAllSpellsOnMe "antimagic shell" 0
#ADDKEY SpellupAllSpellsOnMe "underwater breathing" 0
#ADDKEY SpellupAllSpellsOnMe "protection good" 1
#ADDKEY SpellupAllSpellsOnMe "inertial barrier" 0
#ADDKEY SpellupAllSpellsOnMe "holy aura" 0
#ADDKEY SpellupAllSpellsOnMe "indestructible aura" 0
#ADDKEY SpellupAllSpellsOnMe "grey aura" 0
#ADDKEY SpellupAllSpellsOnMe "spirit shield" 0
#ADDKEY SpellupAllSpellsOnMe "protection evil" 2
#ADDKEY SpellupAllSpellsOnMe "party shield" 0
#ADDKEY SpellupAllSpellsOnMe "totem guidance" 2
#ADDKEY SpellupAllSpellsOnMe "totem force" 2
#ADDKEY SpellupAllSpellsOnMe "gaias revenge" 0
#ADDKEY SpellupAllSpellsOnMe "test of faith" 2
#ADDKEY SpellupAllSpellsOnMe "huntmaster" 2
#ADDKEY SpellupAllSpellsOnMe "magic circle" 0
#ADDKEY SpellupAllSpellsOnMe "compression" 0
#ADDKEY SpellupAllSpellsOnMe "avoidance" 0
#ADDKEY SpellupAllSpellsOnMe "displacement" 0
#ADDKEY SpellupAllSpellsOnMe "mental barrier" 0
#ADDKEY SpellupAllSpellsOnMe "flesh armor" 0
#ADDKEY SpellupAllSpellsOnMe "darkness" 0
#ADDKEY SpellupAllSpellsOnMe "stone skin" 0
#ADDKEY SpellupAllSpellsOnMe "barkskin" 0
#ADDKEY SpellupAllSpellsOnMe "armor" 0
#ADDKEY SpellupAllSpellsOnMe "blur" 0
#ADDKEY SpellupAllSpellsOnMe "shield" 0
#ADDKEY SpellupAllSpellsOnMe "thought shield" 0
#ADDKEY SpellupAllSpellsOnMe "line of protection" 0
#ADDKEY SpellupAllSpellsOnMe "globe of invulnerability" 0
#ADDKEY SpellupAllSpellsOnMe "heat shield" 0
#ADDKEY SpellupAllSpellsOnMe "willpower" 2
#ADDKEY SpellupAllSpellsOnMe "warmth" 0
#ADDKEY SpellupAllSpellsOnMe "vaccinate" 0
#ADDKEY SpellupAllSpellsOnMe "acidproof" 0
#ADDKEY SpellupAllSpellsOnMe "energy shield" 0
#ADDKEY SpellupAllSpellsOnMe "shockproof" 0
#ADDKEY SpellupAllSpellsOnMe "holy mirror" 0
#ADDKEY SpellupAllSpellsOnMe "toxic resistance" 0
#ADDKEY SpellupAllSpellsOnMe "power projection" 2
#ADDKEY SpellupAllSpellsOnMe "air focus" 2
#ADDKEY SpellupAllSpellsOnMe "water focus" 2
#ADDKEY SpellupAllSpellsOnMe "fire focus" 2
#ADDKEY SpellupAllSpellsOnMe "earth focus" 2
#ADDKEY SpellupAllSpellsOnMe "elemental ward" 2 </value>
</alias>
And this was the result of #SHOW @SpellupAllSpellsOnMe
air focus=2|shockproof=0|inertial barrier=0|detect invis=2|giant strength=0|water focus=2|divine swiftness=0|enhanced strength=0|elemental ward=2|wolf spirits=0|mental barrier=0|indestructible aura=0|sense anger=2|godly embrace=0|mystic might=0|compression=0|magic circle=0|earth focus=2|underwater breathing=0|barkskin=0|blur=0|acidproof=0|toxic resistance=0|displacement=0|sanctuary=0|true seeing=0|thought shield=0|combat mind=2|levitation=0|grey aura=0|armor=0|detect good=2|channel energy=0|rally=2|self harmony=0|party shield=0|avoidance=0|fly=2|huntmaster=2|night vision=0|flesh armor=0|warmth=0|protection evil=2|totem force=2|perception=0|shield=0|detect magic=2|darkness=0|heat shield=0|intellect fortress=0|frenzy=0|harden body=0|detect hidden=2|energy ball=0|holy aura=0|pure faith=2|accelerate=0|call upon faith=2|energy containment=0|power projection=2|pass door=0|divine faith=2|party harmony=0|vaccinate=0|calculation=0|gaias revenge=0|adrenaline control=0|spirit shield=0|haste=0|awakening=0|holy mirror=0|sustenance=2|revelation=0|bless=0|stone skin=0|biofeedback=2|globe of invulnerability=0|test of faith=2|wraith form=2|energy shield=0|line of protection=0|antimagic shell=0|willpower=2|fire focus=2|ectoplasmic form=2|detect evil=2|lightspeed=0|totem guidance=2|prayer of fortune=0|aid=0|power of faith=0|magical rush=0|protection good=1|champions strength=0|enlightenment=0|absorb=0
...
same thing as earlier, not the order it needs to be.
//DanteX |
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Thu Nov 05, 2009 4:09 pm |
Hmm. That's very odd indeed. I suppose one workaround would be to do something like:
#ADDKEY variable {0001} {spell#1|Value (0 or 2 or whatever}
Then use %item to pull the values from it. Then it can be sorted numerically.
One thing to do is make sure the Sorted checkbox isn't checked.
Of course, you could always finger my character and get the spellup script from the site listed! :p I should update it, though. Heh.
Charneus
Edit: The reason for the 000 bit is because CMUD cannot sort numerically like we would want. It would go 1, 10, 2, 3, 4, etc. With the leading 0s, it can sort numerically. |
|
|
 |
DanteX Apprentice
Joined: 13 Aug 2007 Posts: 166
|
Posted: Thu Nov 05, 2009 5:09 pm |
Nod Char, there are various ways to solve the problem in the script, that's not the problem. I would like to have it confirmed from Zugg that it's supposed to be the way it is. It might be for various adressing issues within the fuctions... Because if that is the case... I can't say I agree with having it that way. It should then be an option to either
a) have the keys in the order the coder wants
or
b) have it in a CMUD-optimal order
Because this variable decides the order in which spells are cast in the spellup script, and the variable is made by the script... which is why it's important that the order CAN be decided by the coder.
If it is sorted to optimize the fuction, I would like to point out that scripts that COULD rely on the database placement to keep track of order would need additional code to both keep track of order and values... and I don't see it making sense that a (string list + db) accessing like this is faster than only db acessing where the keys and values are in a user-defined order. |
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Thu Nov 05, 2009 5:15 pm |
Definitely. I agree that while there are workarounds, it does need to be addressed. :p
Just to be sure, you don't have any other variation of that variable, do you? Also, does it do the same in an untitled session? I'd test it myself, but ugh... I hate not having a place for a computer.
Charneus |
|
|
 |
DanteX Apprentice
Joined: 13 Aug 2007 Posts: 166
|
Posted: Thu Nov 05, 2009 5:17 pm |
Check my second post, it applies for a new / empty session.
|
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Thu Nov 05, 2009 6:17 pm |
Hah. Ok. Sorry, must have missed it, then. I think most times when I'm on the phone reading, I sometimes skip over things.
In this case...
Zugg, is there any way to "fix" this issue? I could swear that it remained in order before, so I'm not sure why it doesn't now.
DanteX, don't suppose you have an older version of CMUD to test on either, eh? Guess you could do the official release of 2.37 and install it to its own directory. :p
Charneus |
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Thu Nov 05, 2009 6:44 pm |
Datarecord variables in CMud are stored using a hash table, so there's no way to retain a specific sort order. Stringlists are not stored in a hash table, though there's an option to sort them alphabetically or not.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
 |
DanteX Apprentice
Joined: 13 Aug 2007 Posts: 166
|
Posted: Thu Nov 05, 2009 7:10 pm |
Is there any way to change that in order to obtain orders? At least to have it as an option... to get it the way it was in zmud?
|
|
|
 |
wrym Magician
Joined: 06 Jul 2007 Posts: 349 Location: The big palace, My own lil world
|
Posted: Thu Nov 05, 2009 11:07 pm |
the hash tables give greater speed when dealing with large database records. for some reason i'm thinking string lists are hash tables with a numerical index as well. I think what i'ld do is set up 2 variables a stringlist with the order of keys of the database record and the database record then you could
Code: |
#forall @orderedkeys {
#local $val = %db(@databaserecord,%i)
do stuffs
}
|
|
|
_________________ "To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle |
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Thu Nov 05, 2009 11:21 pm |
Hah. Now that I think about it, that's exactly how the spellup script I mentioned works. Heh.
Another option (and it might be faster, not sure) is to use lua tables. I think that might retain order correctly. I could be wrong, though.
Don't think Zugg can do much with the way the hash tables are stored, though. Hmmm.
Charneus |
|
|
 |
DanteX Apprentice
Joined: 13 Aug 2007 Posts: 166
|
Posted: Fri Nov 06, 2009 12:11 am |
I guess I got no choice but to rewrite the script then.
Thanks for the help guys! :)
I'll try to do something like that shown above... Didn't think of it like that first :) |
|
|
 |
GeneralStonewall Magician
Joined: 02 Feb 2004 Posts: 364 Location: USA
|
Posted: Fri Nov 06, 2009 12:39 am |
wrym wrote: |
the hash tables give greater speed when dealing with large database records. for some reason i'm thinking string lists are hash tables with a numerical index as well. I think what i'ld do is set up 2 variables a stringlist with the order of keys of the database record and the database record then you could
Code: |
#forall @orderedkeys {
#local $val = %db(@databaserecord,%i)
do stuffs
}
|
|
This is most likely the best solution for your problem. It's how the majority of my scripts using database variables work. |
|
|
 |
DanteX Apprentice
Joined: 13 Aug 2007 Posts: 166
|
Posted: Fri Nov 06, 2009 2:28 am |
Thanks alot people, I've changed the atm-intresting part of script to what you suggested, and it works :)
|
|
|
 |
|
|