Search FAQ

Gammon Forum

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.
 Entire forum ➜ MUSHclient ➜ General ➜ Bracket capture for triggers

Bracket capture for triggers

Posting of new messages is disabled at present.

Refresh page


Posted by Xandler   (52 posts)  Bio
Date Tue 02 Jul 2024 06:51 PM (UTC)
Message
Sorry if this was posted somewhere else and I didn't see it, I've been browsing the forums looking for similar but couldn't find any applicable. Long story short, I play on a mud that sometimes has brackets ([]) around the text and I'm trying to capture that text and send it to a variable to add it up ie [Double Points] You have gained x [*clan] clan points for doing y.

What I currently have is:

<triggers>
  <trigger
   enabled="y"
   group="CP_Count"
   match="^([Double Clan Points] )?(\w+) (have|has) earned (\d+) [\*clan] clan point from (your|their) valiant effort in slaying (.+)!?"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>CP = tonumber (GetVariable ("CP")) or 0
CP = CP + %3
SetVariable ("CP", CP)</send>
  </trigger>
</triggers>

Do note that this match was given to me by someone using a different client (that uses LUA) but it's still LUA based
I've been testing that with the manual test trigger function in mushclient and it just stays at 0 matches, I'm at a loss on how to make it work. Is there anything simple I'm just not seeing?
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 02 Jul 2024 08:44 PM (UTC)

Amended on Tue 02 Jul 2024 08:45 PM (UTC) by Nick Gammon

Message
To match round or square brackets in a regular expression, just put a backslash in front of it, so for example \[foo\] would match [foo].

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Xandler   (52 posts)  Bio
Date Reply #2 on Wed 03 Jul 2024 02:14 AM (UTC)

Amended on Wed 03 Jul 2024 02:16 AM (UTC) by Xandler

Message
Nick Gammon said:

To match round or square brackets in a regular expression, just put a backslash in front of it, so for example \[foo\] would match [foo].


So, in theory it should be

^\[Double Clan Points\] (.*?) (has|have) earned (.*?) \[\*clan\] clan (.*?) from (your|their) valiant effort in slaying (.*?)!$


But that isn't matching either?
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 03 Jul 2024 07:06 AM (UTC)
Message

 ie [Double Points] You have gained x [*clan] clan points for doing y.


OK, you need to show exactly what arrives from the MUD.


Your trigger was "[Double Clan Points]" so that is not the same as [Double Points] is it?

Then you say "for doing y" which is not the same as "from (your|their) valiant effort in slaying" is it?

You may be paraphrasing, but in order to help we need to see the exact message coming from the MUD.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Xandler   (52 posts)  Bio
Date Reply #4 on Wed 03 Jul 2024 08:24 PM (UTC)

Amended on Thu 04 Jul 2024 01:58 AM (UTC) by Xandler

Message
Nick Gammon said:


 ie [Double Points] You have gained x [*clan] clan points for doing y.


OK, you need to show exactly what arrives from the MUD.


Your trigger was "[Double Clan Points]" so that is not the same as [Double Points] is it?

Then you say "for doing y" which is not the same as "from (your|their) valiant effort in slaying" is it?

You may be paraphrasing, but in order to help we need to see the exact message coming from the MUD.


The exact match is:

^\[Double Clan Points\] (.*?) (has|have) earned (.*?) \[\*SDS\] clan (.*?) from (your|their) valiant effort in slaying (.*?)!$


I've tried numerous times "testing" it with the test trigger for mushclient and unable to get it to have a match.
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #5 on Wed 03 Jul 2024 11:56 PM (UTC)
Message
OK, that's the trigger. Now post the message from the MUD that it is supposed to match, but is not matching.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Xandler   (52 posts)  Bio
Date Reply #6 on Thu 04 Jul 2024 02:03 AM (UTC)
Message

[Double Clan Points] You have earned 2 [*SDS] clan point from your valiant effort in slaying Lootie the Living Loot Box!

Supposed to match that (for example) but with You, the actual number, point, your, and the *mob name* substituted out like in the trigger, if that makes sense.
Top

Posted by Fiendish   USA  (2,533 posts)  Bio   Global Moderator
Date Reply #7 on Thu 04 Jul 2024 04:55 PM (UTC)

Amended on Thu 04 Jul 2024 05:42 PM (UTC) by Fiendish

Message
The regular expression
^\[Double Clan Points\] (.*?) (has|have) earned (.*?) \[\*SDS\] clan (.*?) from (your|their) valiant effort in slaying (.*?)!$

does match the line
Quote:
[Double Clan Points] You have earned 2 [*SDS] clan point from your valiant effort in slaying Lootie the Living Loot Box!


I tested it, and sending print("%1", "%2", "%3", "%4", "%5", "%6") did the right thing.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Xandler   (52 posts)  Bio
Date Reply #8 on Thu 04 Jul 2024 08:52 PM (UTC)
Message
Fiendish said:

The regular expression
^\[Double Clan Points\] (.*?) (has|have) earned (.*?) \[\*SDS\] clan (.*?) from (your|their) valiant effort in slaying (.*?)!$

does match the line
Quote:
[Double Clan Points] You have earned 2 [*SDS] clan point from your valiant effort in slaying Lootie the Living Loot Box!


I tested it, and sending print("%1", "%2", "%3", "%4", "%5", "%6") did the right thing.


That is really strange because I can't get it to "match" on the mud at all but this will match:


<triggers>
  <trigger
   enabled="y"
   group="CP_Count"
   match="^(\[Double Clan Points\] )?(\w+) (have|has) earned (\d+) [\*SDS] clan point from (your|their) valiant effort in slaying (.+)!?"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>CP = tonumber (GetVariable ("CP")) or 0
CP = CP + %4
SetVariable ("CP", CP)</send>
  </trigger>
</triggers>
Top

Posted by Nick Gammon   Australia  (23,122 posts)  Bio   Forum Administrator
Date Reply #9 on Thu 04 Jul 2024 11:19 PM (UTC)
Message
You omitted the final $ from the regular expression so maybe there is a space at the end of the line from the MUD.

- 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.


2,870 views.

Posting of new messages is disabled at present.

Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.