Register forum user name 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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ having trouble with multi-line trigger

having trouble with multi-line trigger

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


Posted by Lilbopeep   USA  (42 posts)  Bio
Date Fri 06 May 2011 07:36 PM (UTC)

Amended on Fri 06 May 2011 07:59 PM (UTC) by Lilbopeep

Message
I have been working on a stat roller but I can't seem to get a multi-line match going despite different attempts at the regexp based on other forum posts..



       Power: 19 (Strong)
Coordination: 14 (Nimble)
   Toughness: 15 (Fit)
Intelligence: 14 (Smart)
      Wisdom: 14 (Thoughtful)
  Appearance: 14 (Pretty)
       Karma: 14 (Lucky)
       Total: 104


The multi-line I have is:

^Power\:\s*(\d+)\s*\((.*?)\)\n\s*Coordination\:\s*(\d+)\s*\((.*?)\)\n\s*Toughness\:\s*(\d+)\s*\((.*?)\)\n\s*Intelligence\:\s*(\d+)\s*\((.*?)\)\n
\s*Wisdom\:\s*(\d+)\s*\((.*?)\)\n\s*Appearance\:\s*(\d+)\s*\((.*?)\)\n\s*Karma\:\s*(\d+)\s*\((.*?)\)\nTotal\:\s*(\d+)\Z

I basically added a colournote just to see if I could get a match, but it hasn't matched yet, as confirmed in the dialog box for the trigger.

its enabled, ignore case, keep evaluating, regular expression, multi-line match is set to 8, send to script

what am I doing wrong?

,.~`'~.,Dance Magic Dance,.~`'~.,
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #1 on Fri 06 May 2011 07:50 PM (UTC)
Message
Have you tried writing and testing one line at a time, to see if you can isolate a problem spot?

...also, I see "Power", "Coordination", "Toughness", "Appearance", "Karma" in the output, but "Strength", "Dexterity", "Constitution", "Charisma", "Luck" in your regexp. That's guaranteed not to match, regardless of any other errors you might have.

(By the way, I'd change the \((.*?)\) to \([^)]+)\), because .* and .*? can both take longer depending on backtracking. [^)] is guaranteed to stop only on a ).)

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Lilbopeep   USA  (42 posts)  Bio
Date Reply #2 on Fri 06 May 2011 07:58 PM (UTC)
Message
Twisol said:

Have you tried writing and testing one line at a time, to see if you can isolate a problem spot?

...also, I see "Power", "Coordination", "Toughness", "Appearance", "Karma" in the output, but "Strength", "Dexterity", "Constitution", "Charisma", "Luck" in your regexp. That's guaranteed not to match, regardless of any other errors you might have.

(By the way, I'd change the \((.*?)\) to \([^)]+)\), because .* and .*? can both take longer depending on backtracking. [^)] is guaranteed to stop only on a ).)


err, yeah.. I copied the wrong thing. The names are correct, but no I haven't tried one line at a time.

Also are you sure \([^)]+)\) is correct? It gives me umatched parenthesis

,.~`'~.,Dance Magic Dance,.~`'~.,
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #3 on Fri 06 May 2011 08:00 PM (UTC)
Message
Lilbopeep said:
Also are you sure \([^)]+)\) is correct? It gives me umatched parenthesis

Nope, I'm totally unsure.

\([^\)]+)\)

Try that.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Lilbopeep   USA  (42 posts)  Bio
Date Reply #4 on Fri 06 May 2011 08:30 PM (UTC)
Message
I tried line by line like you suggested and it just left me more confused..

Since i was setting the numbers to variables (i.e. pow = tonumber (%1), coo = tonumber (%3)) in order to check for rolls later, it was giving me errors that made sense because I was trying to save where none existed. Each time I added a new stat and increased the multi-line by 1, I could see it matching and erroring on each stat. When I got to the last one and increased my line count to 8, it stopped matching.

I am noticing that sometimes the adjectives are sometimes two words and maybe this is causing the problem with matching correctly

this, btw, is still not working..

\([^\)]+)\)

still too many parentheses and im not sure which way to fix it

,.~`'~.,Dance Magic Dance,.~`'~.,
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #5 on Fri 06 May 2011 08:42 PM (UTC)
Message
Lilbopeep said:
(i.e. pow = tonumber (%1), coo = tonumber (%3))

Here's the thing. %1, @var, etc. are not part of Lua. MUSHclient directly inserts them into the script before it's run. So tonumber(%1) becomes tonumber(100)... but it's already a number, so you can just use %1 directly.

On the other hand, if there's a chance that %1 isn't a number, you need to use tonumber("%1"). The quotes mean that %1 is put into a string, and tonumber() then turns it into a number from within Lua. It'll give a runtime error, rather than a syntax error, if it's not a number.


Lilbopeep said:
\([^\)]+)\)

still too many parentheses and im not sure which way to fix it

Mrrrrgh. No, not enough parentheses. Lets try this again.
\(
 (
  [^\)]+
 )
\)


And... here. \(([^\)]+)\) If this doesn't work, I don't know what I'm going to do. X_X

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Lilbopeep   USA  (42 posts)  Bio
Date Reply #6 on Fri 06 May 2011 10:54 PM (UTC)
Message
I had to take a break but when I came back I realized since the total is just that and I can account for the numbers that make it up, there's no reason to keep track of it and it's the only thing I ended up getting stuck on so I scrapped it.

Everything seems to be working great now, thanks for sticking with me on it, Twisol

,.~`'~.,Dance Magic Dance,.~`'~.,
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #7 on Fri 06 May 2011 11:14 PM (UTC)
Message
No problem! I'm glad you got it working.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
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.


25,978 views.

It is now over 60 days since the last post. This thread is closed.     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.