Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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.
Entire forum
➜ MUSHclient
➜ General
➜ Trigger with line break
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Valentim
(9 posts) Bio
|
Date
| Sat 05 Aug 2023 12:56 AM (UTC) |
Message
| How to create a trigger when there is a limit of 60 characters and after this limit the line is broken.
Example:
Whole Line >> "An Ugly and Stinking Ogre attacked you with a club and hit your arm."
1º Broken Line >> "An Ugly and Stinking Ogre attacked you with a club and hit y"
2º Broken Line >> "our arm."
Note: line break changes according to the text
Trigger: ^(.*) attacked you with a (.*) and hit your (.*)\.$ | Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sat 05 Aug 2023 04:05 AM (UTC) |
Message
| What do you mean by broken line? Does the server do that? It seems odd to break a word in the middle. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Valentim
(9 posts) Bio
|
Date
| Reply #2 on Sat 05 Aug 2023 12:15 PM (UTC) Amended on Sat 05 Aug 2023 02:16 PM (UTC) by Valentim
|
Message
| word wrap is does by server, possibly due to some bidding on screen size, I don't know how to explain.
I already tried to configure client in output options, but it didn't work... I don't know if I did it right
Is there any way to use wildcard as (.*\n) ? | Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #3 on Sat 05 Aug 2023 09:46 PM (UTC) |
Message
| I'm surprised a MUD would break lines in the middle of words. Did you configure MUSHclient to have short lines? If not, surely their server has an option to have longer lines, many servers have a "config" or similar command to do that.
Normal triggers are evaluated on a linebreak, so you therefore can't put a newline into the trigger.
There is an multi-line trigger option, in which case you could look for newlines in a wildcard like you suggested. However I would try to fix the main problem first before attempting that. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #4 on Sun 06 Aug 2023 11:58 PM (UTC) Amended on Mon 07 Aug 2023 12:01 AM (UTC) by Fiendish
|
Message
|
Quote: Is there any way to use wildcard as (.*\n) ?
Given the description of the scenario (splitting in the middle of a word), it sounds like you'd need an optional \n after every single character. Even if that works, it would be very ugly and hard to work with. |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #5 on Mon 07 Aug 2023 05:37 AM (UTC) Amended on Mon 07 Aug 2023 05:42 AM (UTC) by Nick Gammon
|
Message
| This might work for you:
<triggers>
<trigger
enabled="y"
lines_to_match="2"
match="(?s)^.* attacked you with.*\."
multi_line="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
local line = [===[%0]===]
line = string.gsub (line, "\\n", "")
print ("Combined line:", line)
who, weapon, place = string.match (line, "^(.-) attacked you with a (.-) and hit your (.-)%.$")
if not who then
print "No match"
return
end -- if
print ("Who:", who)
print ("With what:", weapon)
print ("Where:", place)
</send>
</trigger>
</triggers>
|
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
What this is doing is using a two-line multi-line trigger to detect both lines. We have to cut down the regular expression in the trigger to just detect "this sort of" line. The final period in the match text is to make it stop when it hits the period at the end of the sentence. The "(?s)" in the regexp tells it to include newlines in the "dot" match.
Then the Lua code gets rid of the newline (if any) and then does a string.match to re-parse the line and extract out the attacker, weapon and place it hits.
Example output from your test data:
Combined line: An Ugly and Stinking Ogre attacked you with a club and hit your arm.
Who: An Ugly and Stinking Ogre
With what: club
Where: arm
The only trouble with this is would be a single-line attack, because the two-line trigger will wait for both lines. For that case you might want to use your original trigger (that matches a single line) to handle that case, and make that a lower sequence number, so that it stops this second multi-line trigger from trying to evaluate. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Fiendish
USA (2,533 posts) Bio
Global Moderator |
Date
| Reply #6 on Mon 07 Aug 2023 03:51 PM (UTC) Amended on Mon 07 Aug 2023 03:54 PM (UTC) by Fiendish
|
Message
| match="(?s)^.* attacked you with.*\."
I was thinking more like
match="(?s)^.* \n?a\n?t\n?t\n?a\n?c\n?k\n?e\n?d\n? \n?y\n?o\n?u\n? \n?w\n?i\n?t\n?h\n?.*\."
:D |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #7 on Mon 07 Aug 2023 08:09 PM (UTC) |
Message
| Yeah, well I was kind-of hoping the mob's name wouldn't be so long it would push the rest past a line break. I suppose you could match "anything" and then do the decoding in the trigger. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
5,762 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top