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
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Wed Jul 23, 2008 1:33 pm   

using a stringlist as a trigger question
 
trying to consolidate a TON of my triggers into one stringlist trigger, per the "speed" thread that had a ton of great information on it. having said that. the basic format is:

Code:
#var testlist {item one|item two|item three}
#trig {^{@testlist}.$} {#say this is an item}


right?

well, my question comes up, in that the items in the stringlist, can they have wildcards? also, how do you account for an OR inside of the trigger, using the | right? but i'm missing something, for example...

Code:
#var testlist {the sun comes up over the (%w) horizon today|You notice (*)'s are now dried up|There is only (%d) ticks left in the battle}
#trig {^{@testlist}{.|!}$


test triggers wrote:
On Trididon, the sun comes up over the western horizon today.
Here, the sun comes up over the northern horizon today!
You notice all your potion's are now dried up!
You notice two vial's are now dried up.
There is only 4 ticks left in the battle.


if i can get this down, then all my triggers are gonna get a comb thru, after that... on to regex triggers! weeeee! thanks in advance! =]
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Jul 23, 2008 2:54 pm   
 
#TR {^{%%string(@testlist)}{.|!}$}

That should work. Im not sure if you havta have it checked or not anymore but theres a preference for Allowing wildcards in {} within patterns. Mine is checked and I have something similar.
Reply with quote
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Wed Jul 23, 2008 3:17 pm   
 
hrmmm.... this doesn't seem to be working for me:

Code:
#var testvar {(%w) is afk|(%w) is sleeping|(%w) is not online}
#trig {^{%%string(@testvar)}{.|!}$}

John is sleeping! gives me Pattern does not match
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Jul 23, 2008 3:36 pm   
 
Zugg needs to look at this...

Code:

<trigger priority="11550" id="1155">
  <pattern>^{%%string(@test1)}$</pattern>
  <value>#SAY test</value>
</trigger>
<var name="test1" type="Literal" id="1154">"(%w) is afk"|"(%w) is sleeping"|"(%w) is not online"</var>


Gives me a Perl Regex of

Code:

^(?:(\a+) is sleeping|(\a+) is not online|(\a+) is afk)|string(|string()$


Im not that good with regex, but it looks very wrong.

It should just be
Code:

^(?:(\a+) is sleeping|(\a+) is not online|(\a) is afk)


ALSO, this maybe should be in another thread, but I've noticed theres no xml tab in a stringlist variable. But on a regular string(literal) variable there is.
Reply with quote
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Wed Jul 23, 2008 3:45 pm   
 
Huh, so, what your say'n, is that there isn't anything wrong with that trigger, or the stringlist? IE the (%w), right? For a word... Singly, of course. Back to the regex again, hahahaha! Damn I need to get this ironed out, so I can start reading, LoL
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Jul 23, 2008 3:49 pm   
 
There shouldnt be, I do basicly the same thing your doing with {%%dbkeys(@var)} and its working fine.
Reply with quote
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Wed Jul 23, 2008 4:02 pm   
 
So what does the %%string do, basically define what that variable is, so it knows how to work with the information? Why won't the patterns match for me tho? Is it my stringlist, and the wildcards therein that aren't working?
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Jul 23, 2008 4:15 pm   
 
Im not sure, there was a whole issue with wildcards in string lists a few releases back. All I know is to allow wildcards you have to encase it in %%string() or %%dbkeys() (if its a dbvar obviously). Hopefully Zugg will be around soon to clear anything up and take a look at that unusual regex pattern.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Jul 23, 2008 5:00 pm   
 
Not sure what is going on here, but it looks like %%function syntax is broken in the latest version. Not sure how it got broken since I haven't been working on this lately, but I can't even get %%dbkeys to work anymore.
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Jul 23, 2008 6:04 pm   
 
Zugg-

Forgot to mention... I posted that xml from 2.32. So looks like it was broken before 2.33 too. Also my %%dbkeys() seems to work fine in my current setup.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Jul 23, 2008 6:26 pm   
 
If your %dbkeys is working, can you post the XML for it? Look at the Compiled Pattern tab...that will show if it is properly calling the %dbkeys function or not.

Also, if anyone can determine when this became broken, that would help me figure out the cause. I'd hate to "fix" it and just cause something else that I already fix to break again too.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Jul 23, 2008 6:50 pm   
 
Code:

#var testlist {the sun comes up over the (%w) horizon today|You notice (*)'s are now dried up|There is only (%d) ticks left in the battle}
#trig {^{@testlist}{.|!}$

I played with triggers like this a few months ago and found that something like the above will not work as you expect. If it catches a line like:
Code:

the sun comes up over the eastern horizon today.

then "eastern" will be stored in %1. But if it catches:
Code:

You notice the apple's are now dried up.

then "the apple" will be stored in %2. It counts parentheses from the beginning of the entire pattern, and the whole stringlist is part of the pattern. So, if you didn't know about this, it will throw a wrench into your works.
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Jul 23, 2008 7:15 pm   
 
Here is my compiled Pattern...
Code:

0000   STR   '^'
0012   STR   '{'
0024   STR   '%%dbkeys('
0044   VARPATREF   @spellscastmsg <spellscastmsg>   (class Davos)   
0076   CONCAT   
0080   STR   ')'
0092   CONCAT   
0096   CONCAT   
0100   STR   '}'
0112   CONCAT   
0116   CONCAT   
0120   STR   '$'
0132   CONCAT   


here is the xml for the trigger...
Im not going to post the dbvar because its quite huge, but its basicly the same thing as the stringlist already listed...

Code:

<trigger priority="21810" id="272">
  <pattern>^{%%dbkeys(@spellscastmsg)}$</pattern>
  <value>#SUB {@cyan("Now affected by") @orangered(%proper(%db(@spellscastmsg, %replace(%trigger,%1%2%3%4%5%6%7%8%9%10,"(%w)"))))}
#IF (@spellsoff <= 0) {} {#MATH spellsoff (@spellsoff - 1)}
#IF (%ismember( %replace(%trigger,%1%2%3%4%5%6%7%8%9%10,"(%w)"), @VoidSpells)) {} {#DELITEM SpellsToRecast %db(@spellscastmsg, %replace(%trigger,%1%2%3%4%5%6%7%8%9%10,"(%w)"))}
#VAR CastingPause 0
RecastSpellsOnMe</value>
</trigger>


From all my testing... this is still physically working for me. It could still be broken and Im just getting lucky tho.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Jul 23, 2008 8:04 pm   
 
OK, well actually, your %dbkeys isn't working correctly either. You might be getting lucky or something, but you'll notice in the Compiled Pattern that the %%dbkeys reference is being compiled as a string and then concatted to your variable, rather than calling the DBKEYS function like it should.

For example, look at a compiled pattern for a trigger with a pattern of just "%%dbkeys(@spellcastmsg)" and you'll see what I mean in the difference. The fact that the function reference isn't being compiled means that the %%dbkeys function isn't actually being called.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Jul 28, 2008 9:36 pm   
 
This is now fixed in v2.34
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Mon Jul 28, 2008 11:19 pm   
 
Rahab wrote:
Code:

#var testlist {the sun comes up over the (%w) horizon today|You notice (*)'s are now dried up|There is only (%d) ticks left in the battle}
#trig {^{@testlist}{.|!}$

I played with triggers like this a few months ago and found that something like the above will not work as you expect. If it catches a line like:
Code:

the sun comes up over the eastern horizon today.

then "eastern" will be stored in %1. But if it catches:
Code:

You notice the apple's are now dried up.

then "the apple" will be stored in %2. It counts parentheses from the beginning of the entire pattern, and the whole stringlist is part of the pattern. So, if you didn't know about this, it will throw a wrench into your works.



Just use "%params" instead of "%1" it will work how you want it to.
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