Triggers to match with optional prompt

Posted by PJ on Wed 01 Jan 2003 12:19 AM — 5 posts, 21,962 views.

USA #0
(Dont need help, just a tip)

When I use triggers to 'train' certain skills, sometimes my prompt is in front of it, and sometimes it's not, ex:



<100hp 100m 100mv> Your proficiency at blind is 50%

AND

<100hp 100m 100mv>
The day has just begun.
Your proficiency at blind is 50%



I could make a trigger for "* Your proficiency at blind is *" and another for "Your proficiency at blind is *" and have them both send "Cast Blind Dog"
But the more efficient way that I figured out after a bit was "* proficiency at blind is *" so that the first asterisk could either be the prompt and "Your" or just "Your"

Try this for lots of different triggers that seem to only work some of the time...
USA #1
Try making it a regular expression and use:

^(<.*> )?Your proficiency at .* is .*

Basically .* is the same as * in normal triggers, while ^ makes it match on the start of a line only, () creates a 'sub-group' and ? says, 'match this group if it is missing or if it is there one time'. It should match whether the prompt is there or not. ;)
USA #2
Alright, more complicated than mine but pre-made, thanks..
Canada #3
If you are doing something like writing a plugin, you might try an approach like this:
  • Create a regular expression that matches your prompt (but don't use the endline symbol).
  • Put the regular expression into an XML entity.
  • Use the Entity in your trigger code (in the XML file).

By just putting the prompt expression in one place, you allow for relatively easy editing, should that task be required.

One option Nick might consider is allowing for the same, using the Trigger GUI. A field could be established where the user inputs the regular expression that matches their prompt. They could then use one or two new checkboxes in the individual trigger edit screen, perhaps like "[x] Ignore prompt on same line"

Also, a method could be devised where you might put a symbol to indicate you want to use the prompt expression, for example:

Match: %prompt A new day has begun.

Hmm, I forsee a problem with that, since there is an additional space character after the "variable" that you may not want, but can't avoid.
USA #4
You can always use something like %prompt% instead, as in start and end of entity. That way the system knows where it ends. it would probably be better to just have a special trigger named prompt and a setting in all other triggers like: 'Test for Prompt []' If a trigger had this then it could automatically add the prompt you defined to the trigger matching text when finding one. A second option 'Exclude matched Prompt []' would let you return 'only' the part of the line that was found 'after' the prompt, as though there wasn't one there and wildcards would be adjusted accordingly to contain only the wildcard matches of the trigger, not the prompt detected. At least in theory..