Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Breaking a line
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Gremour
(2 posts) Bio
|
Date
| Thu 10 Aug 2006 11:17 AM (UTC) Amended on Thu 10 Aug 2006 12:35 PM (UTC) by Gremour
|
Message
| 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? | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Thu 10 Aug 2006 01:12 PM (UTC) |
Message
| 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.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Gremour
(2 posts) Bio
|
Date
| Reply #2 on Fri 11 Aug 2006 12:16 PM (UTC) |
Message
| Many thanks! Turning EOR/GA replacing solved the problem. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
9,569 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top