It worked perfectly. Thanks!get_counters("Fortune Cookie",0,200) will produce a tab delimited list. So, count the number of tabs? Hmmm... I guess something like this:
PHP:if(get_counters("Fortune Cookie",0,200) == "" || count(split_string( get_counters("Fortune Cookie",0,200), "\t")) != 1) eatsilent(1, $item[fortune cookie]);
boolean cookiecheck() {
if (my_fullness() == fullness_limit()) return true;
matcher cooks = create_matcher("([a-z]*) {0,1}([1-3]{0,1})",vars["auto_semirare"]);
if (!cooks.find()) return vprint("Warning: your auto_semirare setting is not an accepted value: timely|always|never (maximumcounters)",-5);
switch (cooks.group(1)) {
case "timely": if (get_counters("Fortune Cookie",0,200) != "" || get_counters("Semirare window begin",1,200) != "")
return vprint("BBB: No need to eat a cookie given the present counters.","#F87217",8);
if (my_location() != to_location(get_property("semirareLocation")) && $locations[Purple Light District, Haunted Billiards Room,
Menagerie 2, Outskirts of The Knob, Limerick Dungeon, Sleazy Back Alley, Haunted Pantry, Harem] contains my_location())
return vprint("BBB: "+my_location()+" contains a nice semi-rare; not auto-eating cookie. Eat one manually if you want your counterScript to handle it.","#F87217",5);
case "always": case "true":
while (get_counters("Fortune Cookie",0,200) == "" ||
(to_int(cooks.group(2)) > 0 && count(split_string(get_counters("Fortune Cookie",0,200),"\t")) > to_int(cooks.group(2)))) {
if (my_fullness() == fullness_limit()) return true;
if (!eatsilent(1,$item[fortune cookie])) return false;
}
}
return true;
}
matcher cooks = create_matcher("([a-z]+) ?([1-3]?)",vars["auto_semirare"]);
matcher cooks = create_matcher("(timely|always|never) ?([1-3]?)",vars["auto_semirare"]);
@Bale: new BBB will be rolled out within a day or two. Feel free to snatch any of the posted code for eating/parsing the preference to make our scripts play wonderfully together.
int count_counters() {
string counters = get_counters("Fortune Cookie", 0, 200);
if(counters == "") return 0;
return count(split_string(counters, "/t"));
}
boolean toEat() {
if(vars contains "auto_semirare") {
matcher cooks = create_matcher("(timely|always|true|never|false) ?([1-3]?)", vars["auto_semirare"]);
if(cooks.find())
switch(cooks.group(1)) {
case "false":
case "never":
case "timely": return false;
case "always":
case "true": return count_counters() < cooks.group(2).to_int();
}
}
return count_counters() < 1;
}
void eat_cookie() {
if(get_property("semirareCounter").to_int() != last) {
// semi-rare acquired, let's do it again
if(my_fullness() == fullness_limit())
print("If I ate even a fortune cookie I'd burst! Remember to eat a fortune cookie when the tummy is emptier.", "red");
else while(toEat())
eatsilent(1, $item[fortune cookie]);
} else
print("Oops, that wasn't the right number!", "red");
}
The milk will add exactly one adventure, so you'd just have to compare the price of the milk to valueOfAdventure to see if it would be worth it.
int valid_sr_count() {
if (get_counters("Fortune Cookie",0,200) != "")
return count(split_string(get_counters("Fortune Cookie",0,200),"\t"));
int counter_num(string whichcounter) { // returns the first matching counter, or -1 if not found
if (get_counters(whichcounter,0,2000) == "") return -1;
for i from 0 to 2000 if (get_counters(whichcounter,i,i) != "")) return i; return -1;
}
int sr_start() {
return max(0,max(counter_num("Semirare window begin"),70 - my_turncount()));
}
int sr_stop() {
if (get_counters("Semirare window end",1,200) != "") return counter_num("Semirare window end");
if (my_turncount() < 82) return 81 - my_turncount();
return 200 - (to_int(in_hardcore() && !can_drink() && !can_eat()))*80;
}
return sr_stop() - sr_start();
}
// chance that a random lucky number will be valid
valid_sr_count()/300
// chance that a random lucky number will be discarded
1 - (valid_sr_count())/300)
// counters after eating one cookie
1 + 2*(valid_sr_count()/300)