|
Shezmu Wanderer
Joined: 23 Apr 2010 Posts: 53
|
Posted: Thu Jul 08, 2010 4:37 am
Outputting a database variable to screen |
I'm looking for a way to output the information in a database variable into a script, and would like it to appear something similar to below:
DISEMBOWELING=5 | DISMEMBERING=1 | massacring=2
My database variable (@you) appears like this:
Code: |
attacks=8|DISEMBOWELING=5|DISMEMBERING=1|massacring=2|dealt=8000|terminal=0|taken=1500 |
The alias I'm using is:
Code: |
#LOOPDB @you {#if (%pos(%key,taken|dealt|attacks|terminal)>0) {} {#say %key"="%val}} |
Which is outputting like this:
Code: |
DISEMBOWELING=5
DISMEMBERING=1
massacring=2 |
I want it to exclude the keys taken, dealt, attacks and terminal, and just display the damage verbs with their counts.
How do I get the output to appear in a row, as opposed to columns? |
|
|
|
hogarius Adept
Joined: 29 Jan 2003 Posts: 221 Location: islands.genesismuds.org
|
Posted: Thu Jul 08, 2010 4:11 pm |
Use #SAYPROMPT instead of #SAY. Something like the following, which is quick, rough and untested...
Code: |
#LOOPDB @you {#if (%pos(%key,taken|dealt|attacks|terminal)>0) {} {#SAYPROMPT %key"="%val" "}}
#SAY ""
|
|
|
|
|
Shezmu Wanderer
Joined: 23 Apr 2010 Posts: 53
|
Posted: Fri Jul 09, 2010 10:07 pm |
Thanks, Hogarius. This worked. Now, how do I get this output into a variable?
|
|
|
|
hogarius Adept
Joined: 29 Jan 2003 Posts: 221 Location: islands.genesismuds.org
|
Posted: Fri Jul 09, 2010 11:56 pm |
If you are looking to just have the output as just a regular string variable, you can do it like the following, I think. Again, this is quick, rough and untested.
Code: |
@youline = ""
#LOOPDB @you {#if (%pos(%key,taken|dealt|attacks|terminal)>0) {} {youline = %concat(@youline," ",%key,"=","%val)}}
#SAY @youline
|
You can then reuse the value of @youline however you'd like.
(I originally had this in mind, and it's probably better than my original code, because output from the mud won't interfere with output from the script.)
If you are looking to put this in a database variable, I really need to defer to someone who works with database variables on a regular basis. Would someone else like to jump in and help Shezmu out? |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Sat Jul 10, 2010 12:05 am |
I'm not sure what you mean by "get this output into a variable". You already have the information in a variable, @you. What is it you want in this new variable?
|
|
|
|
Shezmu Wanderer
Joined: 23 Apr 2010 Posts: 53
|
Posted: Sat Jul 10, 2010 12:14 am |
Hogarius got what I meant. The @you is a dbvar, which has a few keys that I don't want output in this alias. (It's used for other aliases). I wanted to strip a few of the key/value pairs, and only report the remaining ones.
Hogarius understood my gibberish. Which is kind of scary. Thanks, Hogarius. |
|
|
|
|
|