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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Tue Aug 21, 2001 3:23 pm   

Database variable, sorting
 
There is a database variable, storing information concerning what elixir/salve type is in each vial. There are trigger to set this up, which work fine. The resultant variable looks something like what you would get if you entered this:

#ADDKEY elixlist{12325=health|34552=empty|34562=mending|3554=empty}

When this command is used:
#SHOWDB @elixlist

The following output is gotten:
12325: health
34552: empty
34562: mending
3554: empty

This is kinda nice. But I want it sorted so that all of the empties come one after the other, and all of the healths in a group, etc etc. I couldn't figure it from the help files

Caled
zMud 6.16
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Tue Aug 21, 2001 3:30 pm   
 
I should add that I dont wish to do it by having a #LOOPDB for each elixir-type. The reason is that there are around 35ish possible contents for the vials, and I'd rather not have to write 35 separate thingies if there is a #VIEW or #QUERY way of doing it in a single step....

Caled
zMud 6.16
Reply with quote
Muorshai
Newbie


Joined: 20 Jan 2002
Posts: 3

PostPosted: Sun Jan 20, 2002 7:29 pm   
 
This may be a bit of a late reply, but I'll post it anyway. I may suggest that instead of a database, create a stringlist for each vial type (eg. health, mana, etc) and a stringlist for each type of vial. That way you can cycle through each vial type and the identifiers. (sorry I haven't got the code to post....I'll try to get back to it when I have my files available.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sun Jan 20, 2002 11:21 pm   
 
Try using this alias to sort the items in the variable:
#ALIAS sortByValue {#VAR temp "";#LOOPDB @%1 {#ADDITEM temp %concat(%val, "=", %key)};#VAR temp %sort(@temp);#VAR %1 "";#FORALL @temp {#ADDKEY %1 %word(@temp, 2, "=") %word(@temp, 1, "=")};#UNVAR temp;#GAG}

Kjata
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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