PDA

View Full Version : Lich question



Deathravin
04-05-2008, 12:08 AM
match "StunManSweepToolrackPut", "You have completed this Stun Maneuvers task."
match "StunManSweepMoveAddNM", "repetition(s) remaining."
match "StunManSweepMoveAddNM", "isn't full yet."
fput "Put my bag in bin"
matchwait

What the lines are I'm trying to find...

[You have # repetition(s) remaining.]
-or-
[You have completed this Stun Maneuvers task.]

It's not finding them... I think it's because of the []'s

Deathravin
04-05-2008, 12:25 AM
It's not the [], it's the (s)...

BigWorm
04-05-2008, 04:19 PM
Yeah, parens don't convert correctly to matches. I can't even get "\(string\)" to work and escaping them SHOULD WORK! Note, this a problem with Ruby, not lich. There should be a option like /string/i or /string/g to not interpret any metas in a regex.

Deathravin
04-05-2008, 05:20 PM
<slow, monotone voice>I believe everything and anything rainbow crotch tells me... I will find other way to match what I need... All hail rainbow crotch...</slow, monotone voice>

Shaelun
04-07-2008, 07:54 PM
Off-hand... this is how I'd do it.



lines_to_look_for = [ "You have \d+ repetition(s) remaining",
"You have completed this Stun Maneuvers task",
]
line_that_matched = waitfor( *lines_to_look_for )
reps_remaining = line_that_matched.slice(/\d+/)


The lines_to_look_for variable is an array; this way to add a line that matches, all you have to do is paste it in on a new line. Without going into agonizingly over-descriptive detail, if you put an asterisk in front of an array when passing the array as an argument to a method, then the array isn't passed as a single variable -- its elements are themselves passed as the arguments. Ruby likes to call it "splat" something or other...

e.g., in the above code, that waitfor method will receive exactly the same arguments as it would if you instead wrote it this way:


line_that_matched = waitfor( "You have \d+ repetition(s) remaining", "You have completed this Stun Maneuvers task" )

It may help you to understand whatever isn't working as expected if you bear in mind that most of the very basic methods (match, waitfor, pause, etc.) are meant to be very forgiving and very flexible. That said, I have no idea why a string with parentheses in it wouldn't work; that should be just fine. Make sure it isn't the period that's screwing it up, since it's being interpreted as a "lite" regular expression.