Change line for subsequent trigger matching

Post Reply
LeFey
Posts: 2
Joined: Thu Sep 12, 2013 5:31 pm

Change line for subsequent trigger matching

Post by LeFey »

I would like to do the following

trigger A matches text and removes a portion say: 'patternForA'
so
this is sompatternForAe text
becomes
this is some text

trigger B matches text and does whatever it does say: patternForB -> echo("\ntrigger B matched!")
some text with patternForB
trigger B matched!

What I would like is to be able to have A fire first (easy enough, put it above B in the list) but have B match on the text as altered by A

So if I got from the mud:
Sparky tells you: have you seen the pattepatternForArnForB yet?
I would see
Sparky tells you: have you seen the patternForB yet?
trigger B matched!

Unfortunately I haven't gotten trigger B to match in that situation.

I tried
selectString("patternForA",1)
replace("")

and I see the modified line, but trigger B doesn't fire.

Here's a test run:
> say patternForB patternForA
You say: patternForB
trigger A fired

trigger B fired

> say pattepatternForArnForB
You say: patternForB
trigger A fired
>

Any ideas?

Final note: I'd like this to work for all subsequent triggers, not just a specific trigger B, so I don't think making the two of them a filter chain would work, (unless I made Everything a chain from A? and that just seems wrong.)

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Change line for subsequent trigger matching

Post by Heiko »

As a general rule triggers always match against text from the game. Depending on your specific needs you have a variety of ways to address your problem.
Here's a new detailed explanation of the trigger engine: http://mudlet.sourceforge.net/wordpress ... 1384630528

LeFey
Posts: 2
Joined: Thu Sep 12, 2013 5:31 pm

Re: Change line for subsequent trigger matching

Post by LeFey »

Thank you for responding.

My specific need is this: I'm working on a set of scripts/GUI to implement the Portal MIP, in which the server sends data inline with mud output. I'd like to publish these scripts when I have them working nicely, so I'd like them to work well with other scripts and triggers.

Sometimes the MIP data comes between the beginning of the line and the data sent on the line (usually before the prompt or items listed after the room description), which prevents me from reliably anchoring any regex triggers or using exact match triggers. I've never seen it come in the middle of a line, but the spec does not forbid it.

The MIP data is meant to be removed before output is displayed, and I'd like to be able to remove it before other triggers are checked.

Do you have any suggestions?

Would deleting the line and replacing it work, or would I get multiple firings of substring match triggers?

Should I look into registering it as a protocol, or is the fact that it's inline with the user data a problem for that?

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Change line for subsequent trigger matching

Post by Heiko »

Filtering the input stream before triggers run is impossible. Initially, I had this filter feature on my main feature list in the very beginning of Mudlet, but it wasn't implemented because there are way too few use cases and these cases could be better handled on the server side using the ATCP/GMCP standards. I suggest that you talk with your game admins and add support for one of the two above out of band data channel protocols.

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Change line for subsequent trigger matching

Post by Jor'Mox »

Worst case, you could make a trigger that fires on every line, and run all your "triggers" manually. I.E. replace/delete whatever you need to, then search for trigger sequences using string.match. Less than ideal, but doable. I use something similar to highlight selected character names in my game dynamically.

Post Reply