PDA

View Full Version : Because I was bored: a regex mana check



Gnomad
11-26-2008, 05:08 AM
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

I was bored the other day, and updating my alchemy script to work with my empath's new recipes, when I got tired of having to watch his mana every time I did reps on the training cauldron. As a result, I threw together a quick mana check using MATCHRE. It will check to see if you have 20 mana or more, and send you to the appropriate label.

Feel free to adapt it for your own script if you know what you're doing. It won't work in the Wizard.


MATCHRE mana /Remaining: ([0-9]{3}|[2-9][0-9])$/
MATCHRE nomana /Remaining: ([0-9]{1}|[0-1][0-9])$/
put power
MATCHWAIT

Fair warning: If you double in harness power, this script might not work past level 300 or so.

BigWorm
11-26-2008, 01:46 PM
Not a major issue, but I think your regex with match the wrong label if you have <= -20 mana, although that is quite rare enough that it shouldn't matter.

Bothra
11-27-2008, 01:11 AM
Elegant. I don't fully grasp the syntax but it works. I was wracking my brain over how to efficiently code a mana check. Well done sir.

Jaimaltz
11-27-2008, 01:53 AM
Or you could have just had the script try to send yourself 20 mana, and gone without the regex. You get a different message if you have under 20 mana or if you have more than that. That works in both the wizard and stormfront.

phantasm
11-27-2008, 02:15 AM
Don't trust him, he just wants to report you for scripting.

Deathravin
11-28-2008, 12:49 AM
Ya, I do the thing Jaimaltz sugguested in all my non-lich scripts.