Yet another Hobopolis Town Square phial manager.

greentiger

New member
My manager only handles phials at the moment.


Download to your scripts folder and just set up a mood:

Trigger On: unconditional trigger
Check For: Leave blank
Command: call hoboForm.ash 1

The parameter passed is the number of phials to use at a time.
This script will only check Richard's when you run out of a phial form effect, or every adventure when harvesting skins.

View attachment hoboForm.ash
 

Bale

Minion
I'd just like to share two things. It seems odd to use a regexp to extract the integer from a string already matched with a regexp. Perhaps you do not realize that you can match two strings in a single regexp. Also, switch statements are lovely! In light of those two things I would rephrase part of your script like this:

PHP:
matcher m = create_matcher("\<b\>([0-9]?[0-9]{0,4})\</b\> (pairs of frozen hobo eyes|pairs of charred hobo boots|piles of stinking hobo guts|creepy hobo skulls|hobo crotches|hobo skins)", richard);

while(find(m)){
	print(group(m));
	switch(m.group(2)) {
	case "pairs of charred hobo boots":
		hobophial[0].count = to_int(m.group(1));
		break;
	case "pairs of frozen hobo eyes":
		hobophial[1].count = to_int(m.group(1));
		break;
	case "piles of stinking hobo guts":
		hobophial[2].count = to_int(m.group(1));
		break;
	case "creepy hobo skulls":
		hobophial[3].count = to_int(m.group(1));
		break;
	case "hobo crotches":
		hobophial[4].count = to_int(m.group(1));
		break;
	case "hobo skins":
		skins = to_int(m.group(1));
		break;
	}
}

(Okay, there are more things you can do to improve that regexp, but I'm keeping the lesson short and sweet.)
 
Last edited:

greentiger

New member
Thanks for the comments. That was my first time using regular expressions. I can tell they are powerful, but I'm still just getting my feet wet. Also, I like your code. Does the switch statement need a default or will it just break and the while() will run again? The reason I put in all those checks was because when Richard doesn't have any parts the text is omitted instead of stating he has zero.
 

slyz

Developer
switch() doesn't need a default: if none of the cases match, the program simply continues.
 
Top