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
Zoticus
Beginner


Joined: 16 Jan 2010
Posts: 24

PostPosted: Fri Jul 06, 2012 8:33 am   

Variable Display help
 
Hey -

I've got two variables with data in them, and I'd like to output them on a single line together. I know I can do it like this:

@Weapon.1 has the statistics of @WeaponStats.1

Using #Echo or #Show - but the lists are fluid. There's not always the same number of weapons being checked for statistics. So far, my output alias looks like this:

#forall @probes {#Show "";#EC %i's stats are:}

and it shows each specific weapon on its own line just fine - but how can I get it to display the proper WeaponStats beside?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Fri Jul 06, 2012 12:44 pm   
 
take a look at #SHOWDB?
If you organize your variables right you could do something like....

#FORALL %dbkeys(@weaponStats) {#SAY %i;#SHOWDB @weaponStats.%i}
_________________
Discord: Shalimarwildcat
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Jul 06, 2012 1:54 pm   
 
What exactly is in these variables? I suspect that you have two simple stringlists, is that correct? Or is one of them a database variable? If you are just using stringlists, then a database variable would be the way to go. That's what Shalimar is suggesting. All your data would be in a single variable then, and you could #LOOPDB through it (that's a bit better than #FORALL %dbkeys() )
Reply with quote
Zoticus
Beginner


Joined: 16 Jan 2010
Posts: 24

PostPosted: Fri Jul 06, 2012 8:47 pm   
 
I do have two different stringlists.

I wasn't sure how to capture the information from two different triggers into one variable and have it match up properly.

The first trigger captures the unique item I.D. 'A simple knife'

The second captures the statistics of the weapon which would read something like '40 200 220' once captured.

Edit - Ideally, I'd have a single variable that reads 'A simple knife1' as key, with the value of '40 200 220' and 'A simple knife2' as key with the value of '45 204 203' etc etc. I have the data for both parts, as noted - I just can't figure out how to combine the two.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Fri Jul 06, 2012 10:08 pm   
 
if you know what those values represent you can give them titles

#TR {something to get all the data} {
$name=%1
$str=%2
$dur=%3
#ADDKEY weaponStats.${name} Strength $str
#ADDKEY weaponStats.${name} Durability $dur
}

And so on... or if you just want your method

#ADDKEY weaponstats $name $stats
#ADDKEY weaponstats {sample weapon=20 400 600}
_________________
Discord: Shalimarwildcat
Reply with quote
Zoticus
Beginner


Joined: 16 Jan 2010
Posts: 24

PostPosted: Sat Jul 07, 2012 7:44 am   
 
Quote:
#TR {something to get all the data} {
$name=%1
$str=%2
$dur=%3
#ADDKEY weaponStats.${name} Strength $str
#ADDKEY weaponStats.${name} Durability $dur
}

And so on... or if you just want your method

#ADDKEY weaponstats $name $stats
#ADDKEY weaponstats {sample weapon=20 400 600}


I have one trigger that captures the name, and another that captures the stats - there's no way to have one trigger capture both. I can't get at my client to test atm, but would your examples work to gather data from -two- triggers, rather than one?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Sat Jul 07, 2012 8:20 am   
 
sure, you just neem to store the data from one trigger into a normal variable and reference it in the second trigger
just change it to something like..

Code:
#TR {something to get name} {name=%1}

#TR {something to get stats} {
  #LOCAL $name
  #IF (@name) {$name=%pop(name)} {
    #PRINT {Discarding info, no name to go with it currently stored}
    #EXIT
    }
  $str=%2
  $dur=%3
  #ADDKEY weaponStats.${name} Strength $str
  #ADDKEY weaponStats.${name} Durability $dur
}

I tossed in some error proofing as well, so you dont try to enter something with a %null key
_________________
Discord: Shalimarwildcat
Reply with quote
Zoticus
Beginner


Joined: 16 Jan 2010
Posts: 24

PostPosted: Sun Jul 08, 2012 4:05 am   
 
Thanks, Shalimar! It works wonderfully.

Last question on this topic: Can I use any formatting on this output? Using %ansi tags only colors the first word (meaning, the first statistic output) and using my existing ansi alias changes the output from:

Quote:
[Info]: Dagger126458 has the statistics of:
Damage: 63
To-hit: 225
Speed: 211


to


Quote:
[Info]: Dagger111549 has the statistics of:
[Info]: Damage=78|To-hit=219|Speed=203
[Info]: Dagger126458 has the statistics of:
[Info]: Damage=63|To-hit=225|Speed=211


Now, the second one is nice enough - since, I can use a different ansi alias to change the color to set the statistics apart from my general alias for information subbing. I'm just curious if I can use ansi tags right in the output, to get the coloration I'd like, without the odd output - namely the '=' and '|' inclusion.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Sun Jul 08, 2012 4:51 am   
 
You can try MXP color tags, or alternatively, make new triggers to highlight the end results that get displayed
_________________
Discord: Shalimarwildcat
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