I'm having a difficult time with what, to me, seems like a truly simple problem. But I think my relative newbieness to scripting and creating triggers is hampering me. On one MUD I play, there are two different "afflictions" you can be given which have similar trigger texts. Each trigger requires a different response.
The first trigger text is:
A prickly, stinging sensation spreads throughout your body.
The proper response is:
eat kelp
This I have no problem with. The difficult problem is there's another trigger text designed to beat triggers. What it does is it takes the same text:
A prickly, stinging sensation spreads throughout your body.
And randomly inserts two or three asterisks in place of some letters, for instance:
A pr*ckly, stingin* sensation spreads throughout your body.
The proper response to this is to:
eat bloodroot
Remember, the asterisks are randomly placed.
My original plan was to design two triggers, one that just simply matched the first trigger text and ate kelp and a second that was a regular expression using the |. i.e.
^(A|*) (p|*)(r|)(i|*) . . . etc.
that would eat bloodroot
I quickly realized however, that this setup will also match the text without the asterisks so I'd eat both kelp and bloodroot (which messes things up on the MUD). So no go there. What I thought would be wise would be to eliminate the first trigger and use the regular expression to call a subroutine that would search the text sent by the mud for an asterisk. If asterisk was true, eat bloodroot. If no asterisk, then eat kelp. For the life of me, I can't figure out how to do this.
I'm sure the solution is simple, I just haven't encountered the right function yet. Any help? |