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


Joined: 03 Sep 2007
Posts: 88

PostPosted: Wed Sep 24, 2008 8:54 am   

2.36 Database questions
 
So i recently uncovered the database commands figured it would be pretty useful If i made some sort of relational database...

My main question is- Is there anyway to highlight names based off a database? Just like a simple #trigger {Haldrik} {#cw blue}

But I want it to highlight all names in my database.


Right now I have 2 variable- Flist and flistNotes

flist is key1.2.3. - value friend names

1 brancon
2 suriska
3 dreadnym etc


flistNote is key,value

brancon "Donated 50 gold, cool person"
suriska "taught me to dance"
dreadnym "gave me a sword"



This is just a start, hopefully i can figure out how to expand and add more info etc.


Thanks all!!
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Sep 24, 2008 2:18 pm   
 
Code:
#TR {%%dbkeys(@flistNote)} {#CW blue}

Reply with quote
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Wed Sep 24, 2008 5:28 pm   
 
Toxic wrote:
Code:
#TR {%%dbkeys(@flistNote)} {#CW blue}


Ah, that doesn't seem to work.


Any other ideas? I may try fiddling with this...

Or maybe a different way? maybe by using a string list?



Thanks :0
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Sep 24, 2008 6:34 pm   
 
Thats my fault... try

Code:
#TR {{%%dbkeys(@flistNote)}} {#CW blue}


Thats tested and works
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Sep 24, 2008 8:03 pm   
 
I would suggest just using a string list since you are not actually making any use of a correllation between keys and values. You can convert your current record variable to a string list with:
flistNote=%dbvalues(@flistNote)

The trigger would simply be:
#TRIGGER {%q{@flistNote}%q} {#CW blue}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Sep 24, 2008 8:12 pm   
 
with the above example if your going to use flistnote you would want to do
string = %dbkeys(@flistnote)

If you wanted to use flist then
string = %dbvalues(@flist)

Either way, you don't want to overwrite your dbvar because I'm assuming you WILL use the correllation between keys and values in other scripts.

The other thing is... theres no reason to number your @flist var making it a dbvar. If you wanted to output a numbered list you could simply do this...

#VAR flist {friend1|friend2|friend3}
#LOOP 1,%numitems(@flist) {
#SAY %i". "%item(@flist,%i)
}
Reply with quote
Haldrik
Wanderer


Joined: 03 Sep 2007
Posts: 88

PostPosted: Wed Sep 24, 2008 9:44 pm   
 
Great!

This is all awesome stuff :)

Thanks both of you.

And yes :P I definitely plan on having a correlation... I just gotta figure out where its needed. I'm trying to step outside my box and actually LEARN some of the usefull stuff in cmud. :)
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