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
➜ VBscript
➜ Exp trigger
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Stepelista
(10 posts) Bio
|
Date
| Tue 08 Sep 2009 08:10 AM (UTC) |
Message
| Grettings,
My score looks like this,
-------, the dunedain -------
You are sitting down, relaxing peacefully.
HP: 240/240 END: 240/240 Avg. Stats: 103 Quests done: 125
Current exp: 12734961 (for 3.3 extra levels) Total exp: 12734961
Strength: 103 Agility: 103 Charisma: 103
Constitution: 103 Coordination: 103 Intelligence: 103
Level -- thief, --d --h --m --s old.
My trigger is;
^Current exp: (\w+) ((\w+)% for level) Total exp: (\w+)$
(todo)
setvariable "Exp", "%1"
send to: script
enabled, regular expression, repeat on the same like, expand variables are checked. I also have the same lined trigger as expdiff, but none of them are firing, any idea? | Top |
|
Posted by
| Blainer
(191 posts) Bio
|
Date
| Reply #1 on Tue 08 Sep 2009 08:18 AM (UTC) |
Message
| The first thing I can see is that \w is for word characters \d is for digits. | Top |
|
Posted by
| Blainer
(191 posts) Bio
|
Date
| Reply #2 on Tue 08 Sep 2009 08:23 AM (UTC) |
Message
|
^Current exp\: (\d+) \(for (\d+\.\d+) extra levels\) Total exp\: (\d+)$
Will capture the third line of that output assuming extra levels always has a decimal. | Top |
|
Posted by
| Blainer
(191 posts) Bio
|
Date
| Reply #3 on Tue 08 Sep 2009 08:30 AM (UTC) Amended on Tue 08 Sep 2009 08:31 AM (UTC) by Blainer
|
Message
| Nick has a good tutorial.
 |
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.
|
And you can use a site like this to build regular expressions.
http://www.regextester.com/ | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #4 on Tue 08 Sep 2009 08:32 AM (UTC) |
Message
|
Quote:
(for 3.3 extra levels)
Your trigger:
You can't just change the word order like that. Is it "for x levels" or "x for level"?
Copy and paste the line you are trying to match to at least get the order of things right. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Stepelista
(10 posts) Bio
|
Date
| Reply #5 on Tue 08 Sep 2009 08:32 AM (UTC) |
Message
| ^Current exp: (\d+) ((\d+)% for level) Total exp: (\d+)$
This one didn't work, I had one working before they changed the score design. I was using (\*?) on that one, I have read some posts about exp triggers, that's why I changed it to (\w+) I want it to capture my current exp. Variables will remain same as the old one was working. I just need a new trigger name to capture my current experience. %1 one. | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #6 on Tue 08 Sep 2009 09:20 PM (UTC) |
Message
| Please look at what you are trying to match:
Current exp: 12734961 (for 3.3 extra levels) Total exp: 12734961
Your trigger will not match:
^Current exp: (\w+) ((\w+)% for level) Total exp: (\w+)$
For one thing, the word "extra" appears in the line, but is not in your trigger.
And, as Blainer said, \w matches a "word" character. From the help: "A "word" character is any letter or digit or the underscore character".
For pure numbers you should be using \d (digits). However that won't match the "3.3" (as in 3.3 extra levels). A better match there would be: [0-9.]+
That would match digits and decimal points. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Stepelista
(10 posts) Bio
|
Date
| Reply #7 on Sun 13 Sep 2009 09:34 PM (UTC) |
Message
| I have read them all, it's just eating my mind, I couldn't write a trigger like which captures only the first digits...
Current exp: 1127772 (25% for level) Total exp: 1127772
I don't care about the (....) thing and total exp, what should I do to just ignore them? I only want my client to capture Current exp: (\d+)
Thanks for the tips you wrote, I have read them and they were very useful but I just couldn't figure it out... | Top |
|
Posted by
| Blainer
(191 posts) Bio
|
Date
| Reply #8 on Sun 13 Sep 2009 11:24 PM (UTC) Amended on Sun 13 Sep 2009 11:33 PM (UTC) by Blainer
|
Message
| This should only capture "Current exp" as %1.
<triggers>
<trigger
enabled="y"
match="^Current exp\: (\d+) \(\d+\% for level\) Total exp\: \d+$"
name="Current_Exp"
regexp="y"
sequence="100"
>
</trigger>
</triggers>
The first set of brackets (\d+) is captured first to %1 and the second set of brackets to %2. We have only one set of brackets in the regex above so there is only %1. To include brackets in text to match you need to escape them with a backslash \ like this \(text\).
In the example above we need to match brackets around this part (25% for level) but not capture it so they need to be escaped with a backlash in front of each bracket \(\d+\% for level\). | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #9 on Mon 14 Sep 2009 10:06 AM (UTC) |
Message
| Well:
(Not a regular expression).
Wildcard 1 will be current experience, and wildcard 2 everything else you don't care about. |
- 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.
30,258 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top