[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Lua Plugin Help

Lua Plugin Help

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Calicoxx   (14 posts)  [Biography] bio
Date Sat 19 Sep 2009 03:51 PM (UTC)
Message
So I am trying to make a redirect trigger that when a certain event comes up, it redirects it to Gammon's Chat Redirector. I've added a few things specific to my MUD, but one that I can't seem to figure out goes something like this:

<trigger
	enabled="y"
	match="^[(.*?)\Bonus +(.*?)*$]"
	regexp="y"
	script="redirect"
	sequence="100"
	>
</trigger>


I'm trying to match anything within the [ Bonus + ], but I believe I'm using the wrong character to signify the bonus obtained, or that the syntax in the match is messed up itself.

Any help would be greatly appreciated.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 20 Sep 2009 12:57 AM (UTC)
Message
Can you show an example line of what you are trying to match?

If you are trying to match something actually in square brackets you need to put a backslash in front of them.

eg. to match [Bonus] you would need to match on:


\[Bonus\]


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #2 on Sun 20 Sep 2009 01:22 AM (UTC)
Message
Also, in your original example, '$]' probably isn't what you want; the $ is an end-of-line anchor. ']$' is what I expect you meant.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Calicoxx   (14 posts)  [Biography] bio
Date Reply #3 on Sun 20 Sep 2009 02:32 AM (UTC)
Message
I'm trying to match anything similar to "[PL Bonus +4]"
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #4 on Sun 20 Sep 2009 03:58 AM (UTC)
Message
Try: \[(.*?)Bonus \+(\d+)\]$
[Go to top] top

Posted by Calicoxx   (14 posts)  [Biography] bio
Date Reply #5 on Sun 20 Sep 2009 05:48 AM (UTC)
Message
I forgot to mention another one, which is [Exp Bonus], where exp can also be several other words.
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #6 on Sun 20 Sep 2009 08:26 AM (UTC)
Message
Then use the following regular expression: \[(.*?)Bonus(?: \+(\d+))?\]$
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #7 on Sun 20 Sep 2009 08:50 AM (UTC)
Message
I'd try this one instead, because I doubt he's interested in the space just before 'Bonus':


\[(?:(.*?) )Bonus(?: \+(\d+))?\]$

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Sun 20 Sep 2009 08:59 AM (UTC)
Message
Template:regexp Regular expressions
  • Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
  • Also see how Lua string matching patterns work, as documented on the Lua string.find page.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #9 on Sun 20 Sep 2009 01:39 PM (UTC)
Message
Twisol said:

I'd try this one instead, because I doubt he's interested in the space just before 'Bonus':


\[(?:(.*?) )Bonus(?: \+(\d+))?\]$



I was feeling lazy and didn't want to unnecessarily make it more complicated since he presumably would try to take it apart. =p
[Go to top] top

Posted by Calicoxx   (14 posts)  [Biography] bio
Date Reply #10 on Sun 20 Sep 2009 09:36 PM (UTC)
Message
Nah. The first one that was supplied worked, however, there is no plus in the matches for [Exp Bonus], so the plus sign should be omitted. I figured it would look like,

[(?:(.*?) )Bonus]$
[Go to top] 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.


27,161 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]