|
geosmith Wanderer
Joined: 23 Apr 2005 Posts: 57
|
Posted: 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. |
|
|
|
Iceclaw Apprentice
Joined: 11 Sep 2005 Posts: 124
|
Posted: Sat Mar 25, 2006 12:35 am |
#addkey Elixer Health 79
#addkey Elixer Mana 26
#showdb @Elixer |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: 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 |
|
|
|
geosmith Wanderer
Joined: 23 Apr 2005 Posts: 57
|
Posted: 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. |
|
|
|
|
|