Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
grunthork
Novice


Joined: 22 Jun 2009
Posts: 38

PostPosted: Sun Jul 19, 2009 8:15 pm   

match multiple words and store into multiple list db field
 
Sorry if this has been asked, but i've been looking on the forums for 2 days and i can't find anything that matches exactly. I need help.

Here's the scenario:

I'm capturing items into a database using an identify spell. I've successfully captured items with one word, but i have a line that's giving me problems. The line reads:

Item is: MAGIC BLESSED SHATTERPROOF DONATED

I have an "Item is:" field in my database, which is a option list, allowing for multiple selections. I have the trigger currently setup as:
#TR {Item is: &{item.item is} {#CW white} "identify"

The entire line is colored white, which leads me to believe it matches the pattern, but nothing is added to my database "Item is:" field. I'm pretty sure this is my fault, but i need some help. How can i capture each one of those into the field? Any help is much appreciated.


Thanks,

Gman
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Jul 19, 2009 9:00 pm   
 
Option lists prefer to be comma seperated. Also make sure the database field allows multiple options. Use %replace to change all the spaces to commas.
#TR {Item is: (*)} {#CW white;#ADDKEY item {item is} {%replace(%1," ",",")}} "identify"
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
grunthork
Novice


Joined: 22 Jun 2009
Posts: 38

PostPosted: Mon Jul 20, 2009 3:38 am   Solved!
 
Thanks Vij. Now that you've explained it, I did see something like this in another post (probably answered by you). I just didn't understand what replace was doing. I'll break it down here, so hopefully it helps others know what this is doing. Thanks again, it worked on the first try!

#TR {Item is: (*)} {#CW white;#ADDKEY item {item is} {%replace(%1," ",",")}} "identify"

#TR {Item is: (*)}
This captures everything after "Item is:" from the mud.

{#CW white;
This just colors the text white so that I can tell what is being captured when I identify something. (my default text is green, so white works well)

;#ADDKEY item {item is}
This adds the captured text into my record variable, called "item," into the "item is" field.

{%replace(%1," ",",")}} "identify"
This part replaces every space in the captured variable to commas, which is what is stored into the database. The "identify" at the end is just the name of the class that my idents are in.

So when this:
Item is: MAGIC BLESSED SHATTERPROOF DONATED

Is printed from the mud, it's captured into my "item.item is" variable like this:
MAGIC,BLESSED,SHATTERPROOF,DONATED

Very nice! thanks again Vijilante! Truly you are a guru, as your forum title suggests!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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