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


Joined: 23 Apr 2010
Posts: 53

PostPosted: 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?
Reply with quote
hogarius
Adept


Joined: 29 Jan 2003
Posts: 221
Location: islands.genesismuds.org

PostPosted: 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 ""

Reply with quote
Shezmu
Wanderer


Joined: 23 Apr 2010
Posts: 53

PostPosted: Fri Jul 09, 2010 10:07 pm   
 
Thanks, Hogarius. This worked. Now, how do I get this output into a variable?
Reply with quote
hogarius
Adept


Joined: 29 Jan 2003
Posts: 221
Location: islands.genesismuds.org

PostPosted: 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. Confused Would someone else like to jump in and help Shezmu out?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: 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?
Reply with quote
Shezmu
Wanderer


Joined: 23 Apr 2010
Posts: 53

PostPosted: 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.
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