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
Torin
Novice


Joined: 16 Apr 2008
Posts: 37

PostPosted: Mon Jan 12, 2009 1:17 am   

Database variable in trigger pattern not always matching [solved]
 
I've got a "Database record" variable that contains text that would display from MUD output, namely the "short" description of mobs stored as the Key. (what you see when you look at the room.. i.e. A fido is standing here.) I then have some stuff to parse for that mob, stored as the Value. This database variable is named @preplist

I then have a trigger with the pattern of: (@preplist)

If I only have 1 record, it functions correct. Let's say I have the following record...

Key: A fido is standing here.
Value: fido,blind

The action of my trigger is to check for an %ismember match for @target (the variable that stores the name of my target keyword) on %db(@preplist,%1), to see if there is a match to the text that comes before the comma in the Value field. In this case, if @target=fido and I see "A fido is standing here.", the trigger will fire and take action.

Now, the problem comes in if there is more than 1 record in my database variable, it will not ever cause the trigger to fire, much less action to be taken. Putting the keyword matching business aside, Just having a list of 10 mob "short descriptions" like "A fido is standing here." and "A savage dog is hunched over a dead body.", would not trigger on seeing any of them. 1 record, everything works like butter. More than 1 record? Nothing works.

Is there something I am missing? I tried this before with a stringlist as the trigger pattern (i.e. (@stringlist)) and it works well, didn't matter if I had 100 items in it. But a database variable? Nope. Works fine with 1 record, doesn't work with any more. Am I doing something wrong?


Last edited by Torin on Mon Jan 12, 2009 9:42 pm; edited 1 time in total
Reply with quote
shalimar
GURU


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

PostPosted: Mon Jan 12, 2009 1:54 am   
 
you need to surround it like so
#TR {{@preplist}} {do stuff}
_________________
Discord: Shalimarwildcat
Reply with quote
Torin
Novice


Joined: 16 Apr 2008
Posts: 37

PostPosted: Mon Jan 12, 2009 4:15 pm   
 
Roger that.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Mon Jan 12, 2009 7:48 pm   
 
That's a nifty shortcut syntax, Shalimar, all this time I've been using %dbkeys().

The reason why it didn't work is like this: Patterns use the pipe character | to denote an OR, so if you have string1|string2 it will match string1 or string2. If you have a string list, the items in it are literally separated by a pipe character (you can see this in the settings editor by switching type to string literal for one of your string lists), so it just shoves that into the pattern... if you had a string list with item1, item2, and item3, it would be exactly the same as putting item1|item2|item3 into your pattern, except that it will update if you change the value of the variable (CMud literally rewrites the pattern every time the variable changes). Because db variables have both a key and a value, they're stored a little differently, the syntax is like this: key1=value1|key2=value2|key3=value3 and so on... I'm sure your original trigger would have matched on the string key1=value1 (where key1 and value1 are a matching key-value pair in your db), which makes sense.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Jan 13, 2009 2:35 pm   
 
In an earlier version of cmud, there was a bug which prevented that shortcut. To work around it, you needed the %dbkeys. The bug was fixed a few versions ago.
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