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
➜ Lua
➜ trigger issues
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Silencher
(55 posts) Bio
|
Date
| Fri 23 Jan 2015 02:35 AM (UTC) |
Message
| It's been a while since I've used mushclient/lua and I can't remember how to do this anymore.
I'm trying to count the number of items I have in a certain line.
Here's an example of raw-output:
In the leather utility belt you see some average ground arnica (x31), some average ground yora root (x10), some potent ground yora root (x2), some average ground stems of thistleweed (x5) and some potent ground stems of thistleweed.
What I'm trying to do is make triggers for each 'type' of herb that will count the numeric value. My trigger right now is:
.*some average ground stems of thistleweed \(x*\).*
with the body containing:
averagethistleweed = %2
Note (averagethistleweed)
But it doesn't seem to be working. What I was then going to do was have an alias list all these items, but that's a separate issue and one I know how to do. I just can't seem to catch that '5' in the 'average ground stems of thistleweed (x5)' line.
I also have the 'keep evaluating, enabled, and regular expression' boxes checked on the right hand side.
If I can get help with this that would be great. | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #1 on Fri 23 Jan 2015 02:56 AM (UTC) |
Message
| Can you post the actual trigger please?
 |
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
|
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Silencher
(55 posts) Bio
|
Date
| Reply #2 on Fri 23 Jan 2015 03:11 AM (UTC) |
Message
| <triggers>
<trigger
enabled="y"
group="herbcount"
keep_evaluating="y"
match=".*some average ground stems of thistleweed \(x*\).*"
regexp="y"
send_to="12"
sequence="100"
>
<send>averagethistleweed = %2
Note (averagethistleweed)</send>
</trigger>
</triggers> | Top |
|
Posted by
| Slick2175
USA (27 posts) Bio
|
Date
| Reply #3 on Fri 23 Jan 2015 06:25 PM (UTC) Amended on Fri 23 Jan 2015 06:38 PM (UTC) by Slick2175
|
Message
| For one, one of the issues is the trigger is not actually firing. You have nothing in the trigger that captures the actual number. Im assuming you meant to do x.*. Its better and faster to use x/d. /d starts for 0-9.
Try this. You can actually name your wildcards with (?P<name>pattern)
its best if you paste this into mushclient before you try to read it, Pasting this script on the forum changes certain things because of forums code. So it doesnt look exactly right on here, but it will paste correctly into mushclient and show correctly there.
Talks about why things look different on here compared to on the client.
http://mushclient.com/forum/?id=4776&reply=3#reply3
<triggers>
<trigger
enabled="y"
expand_variables="y"
group="herbcount"
keep_evaluating="y"
match="^some average ground stems of thistleweed \(x(?P<ammount>.*)\)"
regexp="y"
send_to="12"
sequence="100"
>
<send>print(%<ammount>)</send>
</trigger>
</triggers>
Also I love this website below if I cant figure out why my regexp trigger is not firing. Note this website doesnt work for lua regexp, but works for the standard regexp used in triggers and alias.
https://www.regex101.com/ | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #4 on Fri 23 Jan 2015 07:47 PM (UTC) |
Message
| There are two sorts of regexp, one is the PCRE one used in triggers and aliases (Perl-Compatible) and the other one is the Lua one used in string.find, string.match etc.
 |
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.
|
Post an example of what is not working, and what you are trying to match on. |
- 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.
17,887 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top