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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Exp trigger
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Exp trigger

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


Posted by Stepelista   (10 posts)  [Biography] 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?
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] 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.
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] 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.
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] 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.
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.

And you can use a site like this to build regular expressions.
http://www.regextester.com/
[Go to top] top

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Tue 08 Sep 2009 08:32 AM (UTC)
Message
Quote:

(for 3.3 extra levels)


Your trigger:


((\w+)% for level)


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
[Go to top] top

Posted by Stepelista   (10 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] 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
[Go to top] top

Posted by Stepelista   (10 posts)  [Biography] 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...
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] 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\).
[Go to top] top

Posted by Nick Gammon   Australia  (21,607 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Mon 14 Sep 2009 10:06 AM (UTC)
Message
Well:


Current exp: * (*


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


6,040 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 FutureQuest]