Breaking a line

Posted by Gremour on Thu 10 Aug 2006 11:17 AM — 3 posts, 12,433 views.

#0
I'm trying to write a set of triggers for a MUD. MUD sends status prompt after each event, and the problem is that prompt is not newline-terminated (I suppose; triggers won't process prompt until line complete, or new line appears). So, sometimes I recieve a text like this:

100h, 100m eb-You eat a chunk of meat.
That was tasty meat!
100h, 100m eb-

And sometimes like that:

100h, 100m eb-
You eat a chunk of meat.
That was tasty meat!
100h, 100m eb-

For a reason, I need to set triggers to react "You eat a chunk of meat." as a string, that begins at the start of line, 'cause I can recieve fake strings like

100h, 100m eb-
Someone says, "You eat a chunk of meat."
100h, 100m eb-

and must ignore them.

I use regular exressions and "^" and "$" symbols, to be sure I don't get fake strings. Now, I'm forced not to use "^", what is a bad idea.


So, I wonder, if there is a way to call triggers processing sequence from the script? So I can set up one trigger which will separate status prompt from the rest of string, and then call triggers sequence again, for the right portion of that line.

Or, maybe, there is another solution to the problem?
Amended on Thu 10 Aug 2006 12:35 PM by Gremour
Australia Forum Administrator #1
There are a few approaches you could take.

  • One is to use the OnPluginPacketReceived callback in a plugin to preprocess the prompt line, where if you find a newline followed by what looks like a prompt, put another newline after it.
  • Some MUDs send a EOR/GA (end of record, go ahead) sequence at the end of the prompt, you can configure MUSHclient to convert that into a newline.
  • What you can also do is make an optional trigger prompt at the start of your other triggers. Say you normally get something like your example (100h, 100m eb-) as a prompt, you can make that optional for other triggers, like this:


    ^(\d+h, \d+m e?b?\-)?You eat a chunk of meat.$


    This is an example, your prompt might be more complex. But the idea is that a whole sequence (in brackets) can be made optional in a regular expression.

#2
Many thanks! Turning EOR/GA replacing solved the problem.