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
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Sat May 24, 2003 7:47 am   

Database searches
 
I can't seem to figure out how to perform searches on the database. What i want to do is either color some text or set off an action whenever someone on my enemy list enters my area. The database is simple, as the field for names is first. The trigger message I will get is like this: Druid Trae has entered the area.

Now I want to be able to run through my database and if it sees Trae, then it will color the text. Is this possible?
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Sun Jun 08, 2003 2:51 pm   
 
OK i will leave your name alone,Dumas.(as I chuckle to my self)

%find and %query are written for just that reason, finding things in the database.

Please read these text in the help files and if you still have questions please feel free to post them.

megamog75
Keeper of the only printable help files for Zmud.
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Sun Jun 08, 2003 5:37 pm   
 
Will do

I got Dumas from the Alexandre Dumas, who wrote The Three Musketeers.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Jun 08, 2003 9:13 pm   
 
Actually, this type of thing is better handled with a list variable containing the names. The original list may be created with either #ADDITEM or #VARIABLE. If you already have the names in a database, #ADDITEM would be ideal for use with #LOOPVIEW. Names may then be added at any time using #ADDITEM and removed at any time using #DELITEM.

Assuming the database is in use with the names in a field called Name and all enemies available from a view named Enemy.
#LOOPVIEW Enemy {#ADDITEM Enemies {&Name}}
#TR {({@Enemies}) has entered the area} {#PCOL hi,red %x1}

LightBulb
Advanced Member
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Mon Jun 09, 2003 12:16 am   
 
#VAR enemy {}
#TRIGGER {(*) has entered the area.} {#var enemy 1;#var enemy %find("%1",names);#if @enemy=1 {} {#PCOL hi,red %x1}}

Lightbuld is correct ofcoars but the above example is what I was refering to.

Hope you got some use out of the help file instead of people just handing you the answers.

Funny how people start helping once I get involved :)

megamog75
Keeper of the only printable help files for Zmud.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Jun 09, 2003 2:51 am   
 
I don't remember seeing this before (although I'm sure I did) or why I might have skipped it the first time around (probably I couldn't think of any way to use the database). But I looked at the date on the original post, and I'm glad you went back and found it. It's always helpful when someone brings up unanswered questions for additional review.

I try to resist the temptation to add my own answer when someone else has provided one, unless I think it's a significant improvement or alternative to the original solution.

LightBulb
Advanced Member
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Tue Jun 10, 2003 4:38 am   
 
Of the two responses, magamog75 worked the best, yet it was coloring every name when I got that message, not just those in my database.
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Tue Jun 10, 2003 10:45 pm   
 
OOps i was too quick to jump to my ending here is the working one.

____________________________________________

#VAR enemy {}
#TRIGGER {(*) has entered the area.} {#var enemy "";#var enemy %find("%1",names);#if @enemy="" {true} {#PCOL hi,red %x1}}

_____________________________________________

Soryy about that sometimes i write them and don't really work out the bugs heheheheh
works now though.

megamog75
Keeper of the only printable help files for Zmud.
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Thu Jun 12, 2003 2:08 am   
 
Okay...got a problem and I want to see if this is what is causing it. When these people enter the area, it displays their whole title/name. Would this interfere with the %find and always come up as true for it not being on my list since they are listed in the DB only with their name?
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Thu Jun 12, 2003 4:23 am   
 
My guess would be yes cut and past a sample or two but since titles can change it would come back as ture in the program i wrote for you and true is NOT in the database.

and therefore should not becoming back colored.

megamog75
Keeper of the only printable help files for Zmud.
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Thu Jun 12, 2003 8:55 am   
 
Vertigo Tervicz has entered the area.

That is a sample of someone entering. Vertigo is his name and Tervicz is his surname. On the enemy list my db is based from he would only be listed as Vertigo.
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Thu Jun 12, 2003 2:33 pm   
 
Vertigo Tervicz has entered the area.

#VAR enemy {}
#VAR enemyname {}
#TRIGGER {(*) has entered the area.} {#var enemy "";#var enemyname "";#var enemyname %replace(%1," ","|");#var enemy %find(%item(@enemyname,1),names);#if @enemy="" {true} {#sub {%ansi(high,red)%item(@enemyname,1) %ansi(high,yellow)has entered the area}}}

Put this inplace of the old one.

Anything else? hehehehehehe

megamog75
Keeper of the only printable help files for Zmud.
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Fri Jun 13, 2003 11:42 am   
 
What does this do exactly? It seems all it does is make Vertigo Tervicz into Vertigo|Tervicz in a stringlist variable. Yet Tervicz is just a last name or may be a title so has no bearing on my db. Now, if the purpose is to then use this stringlist to check the DB for Vertigo and Tervicz then I can see how it may work.
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Fri Jun 13, 2003 6:06 pm   
 
The above script was tested in 6.4 version zmud and worked without fail to find the first item in the variable only.

as stated in you text that the first word is the key and the second word is a last name or title.

I made two seprate test for it to highlight red one test with one name, it worked . and a second test with a first and last name, it worked.

It would take: Vertigo|Tervicz and just search for Vertigo if found color it red if not send true but for you ,you would take out true like this:

#TRIGGER {(*) has entered the area.} {#var enemy "";#var enemyname "";#var enemyname %replace(%1," ","|");#var enemy %find(%item(@enemyname,1),names);#if @enemy="" {} {#sub {%ansi(high,red)%item(@enemyname,1) %ansi(high,yellow)has entered the area}}}

let me know if you have any other questions? :)

megamog75
Keeper of the only printable help files for Zmud.
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