Re: Damage Counter script errors
Posted: Thu Mar 06, 2014 5:05 pm
As a bit of feedback (I can't speak to your problem, because I don't know the script well enough), but you can easily cut down on those crazy table definitions if you modify your pattern a bit.
That one pattern matches all three of your sample strings (verified at http://regexpal.com/).
Then, you can call string.lower() on matches[4] (guessing it's 4 by count). That way, you can dispense with the crazy lookup table entirely. *MANGLING* becomes "mangling", ***DISMEMBERING*** becomes "dismembering", obliterating becomes "obliterating".
This also drastically reduces maintenance burden, as you don't need to deal with _critNames at ALL. Just remove it.
Now, I see there are more special characters in there (<, >, =). I'll leave that as an exercise for you (hint: see the \* in there? Now think of that with []'s around it...).
Code: Select all
^Your attacks? strikes? (?:an?|the) ([\w\s]+) (\d+) times, with \**(\w+)\** (\w+)!$
Then, you can call string.lower() on matches[4] (guessing it's 4 by count). That way, you can dispense with the crazy lookup table entirely. *MANGLING* becomes "mangling", ***DISMEMBERING*** becomes "dismembering", obliterating becomes "obliterating".
This also drastically reduces maintenance burden, as you don't need to deal with _critNames at ALL. Just remove it.
Now, I see there are more special characters in there (<, >, =). I'll leave that as an exercise for you (hint: see the \* in there? Now think of that with []'s around it...).