Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
DefinNormal
Beginner


Joined: 24 May 2012
Posts: 12
Location: United States

PostPosted: Thu May 16, 2013 12:16 am   

iskey and dbkey confusion.
 
So, I'm trying to use a database for curing. The keys are the affliction, and the cure for each (in this case) is stored in the 'Cure' value.

For the affliction 'ablaze', it's: Cure="mending"|Location="torso"


The problem I am having, unless I misunderstand the use of these commands, is that the location of each key in the database is not being returned correctly.

Code:

#SHOW %iskey(Salve,ablaze)
#SHOW %dbkey(Salve,16)


iskey returns 16, so ablaze should be the 16th key in the database.

When I use dbkey to see the 16th key in the database, it's returning 'smashed_throat' - which is in fact the 16th key in the database.


Any ideas on why iskey isn't returning the correct location in the database?




If it helps.. but the issue is that %iskey is not returning the correct record number.

Quote:

#FU SalveAff {#IF (@SalveCheck()) {#IF (%max(@Pre) > 15) {#LOOPDB @Pre {#IF (%max(@Pre) = %val) {ASALVE restoration to %replace(%key,"_"," ");#EXIT}}} {$pri="";$aff="";#FORALL @CSalve {#ADDI $pri %iskey(@Salve,%i)};$aff=%dbkey(@Salve,%min($pri));#IF (@Salve.$aff.Location = skin) {ASalve @Salve.$aff.Cure} {ASalve @Salve.$aff.Cure to @Salve.$aff.Location;#PRINT {$aff}}}}}
Reply with quote
DefinNormal
Beginner


Joined: 24 May 2012
Posts: 12
Location: United States

PostPosted: Thu May 16, 2013 1:52 am   
 
Okay, I closed cMUD and re-opened it, and ablaze is now value 16. However, I do not have any type of sorting on this database variable. Is it possible to prevent it from auto-sorting?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu May 16, 2013 3:38 am   
 
The way datarecord variables are stored internally means there's no way to ensure the order of key-value pairs. You can enforce a temporary sort order via %sort(), but that's going to change just often enough that you can't rely on it.

If you need to ensure position, convert to stringlists instead.
_________________
EDIT: I didn't like my old signature
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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