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
geosmith
Wanderer


Joined: 23 Apr 2005
Posts: 57

PostPosted: Fri Mar 24, 2006 11:54 pm   

Data Record Variables Question
 
I've been working on an elixir-sip counter such that the following MUD output:
Code:
Vial           Elixir                           Sips        Months Left
-----------------------------------------------------------------------             
vial190626     an elixir of health              50          136
vial191616     an elixir of health              29          136
vial192782     an elixir of mana                26          136

..will end up setting variable "healthcount" to 79, and variable "manacount" to 26. This has been relatively simple using the #ADDI command.

However, what I'd ideally like would be instead of having seperate variables for health, mana and the various other elixirs, to have a single data record variable which would list all of them along with the total sips for each. I'm not especially familiar with data record variables though, so any advice on how to impliment this would be appreciated.

Editted: Vijilante, added code tag so mud output spacing could be seen correctly.
Reply with quote
Iceclaw
Apprentice


Joined: 11 Sep 2005
Posts: 124

PostPosted: Sat Mar 25, 2006 12:35 am   
 
#addkey Elixer Health 79
#addkey Elixer Mana 26
#showdb @Elixer
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Mar 25, 2006 4:50 am   
 
For all such things I suggest using a fixed width pattern. Next is the conversions involved; since you only seem to be seeking total sips avaliable per type your should pre-format your data, and use an %eval trick. The basic idea of such a method is that you would set all varieties of 'elixir' to 0 during one of the general lines, then use %concat(@Exisiting.sourceValueForType%X,"+",%Y) At the end you use a #LOOPDB to go through all the different types reassigning them with '#ADDKEY Variable {%key} {%eval(%val)}'.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
geosmith
Wanderer


Joined: 23 Apr 2005
Posts: 57

PostPosted: Sat Mar 25, 2006 12:18 pm   
 
Thanks Vijilante, that put me in exactly the right direction. The only difference is instead of using #LOOPDB to reassess at the end of the list, I created a trigger as follows:

Pattern:
^vial%d*({@elixirs})* (%d)%s%d

Value:
#ADDKEY elixircount %1 %concat(@elixircount.%1,"+",%2)
#ADDKEY elixircount %1 %eval(@elixircount.%1)

Seems to work exactly as wanted.
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