I was originally using a variant of one of the above scripts, but I revisited it yesterday and tried to make it both simpler and thorougher. Reading people's comments etc gave me more ideas. I didn't know, for example, that mafia automatically gets hermit permits and worthless items if you need them when executing hermit(). That makes all the above posts needlessly complex.
Why write another version:
[*]I tend to be fairly anal about keeping server hits low, so although izchak's algorithm is nice, it generates 1 server hit per clover, whereas muffins' version visits the hermit once to see how many, parses the page, and goes once more to get everything. I wanted to retain a minimal-server-hit script.
[*]The hermit page can be parsed more simply.
[*]Some people (especially hardcore) may not want to burn unnecessary adventures in the sewer getting 5 worthless items, so I wanted a smart script that only gets the available amount.
[*]the "haxored" thing could be done much more simply.
This version makes use of mafia's built-in stuff, keeps a lot of good ideas from the above scripts but simplifies a lot of things.
Code:
// take all available clovers from the hermit without apologizing
boolean declover_hermit() {
cli_execute("use * hermit script; use * 31337 scroll");
boolean haxored = contains_text(visit_url("questlog.php?which=3"), "You have summoned the UB3r 31337 HaX0R");
if (!haxored) retrieve_item(1,$item[hermit permit]);
cli_execute("acquire 1 worthless item");
int cloves = 0;
string source = visit_url("hermit.php");
if(contains_text(source, "left in stock for today"))
cloves = to_int(substring(source, index_of(source, " left in stock")-1,index_of(source, " left in stock")));
print("Hermit has " + cloves + " clovers in stock today.","blue");
if (cloves > 0) return hermit(cloves, $item[ten-leaf clover]);
// print("Sorry, hermit."); apology removed
return true;
}
void main() {
declover_hermit();
}
EDIT: added a downloadable version.
EDIT: 31337 scrolls are quest items. Script is now shorter and sweeter.