Help on scripting Nash Crosby's Still

Ptomato

New member
I've been trying to write a script for my logout file, which will use the remaining uses of Nash Crosby's Still to make whichever improved spirit or garnish costs most in the mall, and then put that in my store. However, I discovered on this forum that mall-searching URLs are disallowed in visit_url() so as to prevent mall-botting. I have two questions:

1. Is what I'm trying to do considered mall-botting?
2. If not, is there any other way to do it automatically?

I've included the relevant part of my script here. I'm new to KoLmafia scripting, so please excuse me if I'm missing anything obvious.

Code:
int get_cheapest_mall_price(item it)
{
	// Search the mall for it, only return the one cheapest result
	string input = "searchmall.php?cheaponly=true&shownum=1&whichitem=" 
		+ url_encode(to_string(it));
	string result = visit_url(input);
		
	print("Debug: " + result);
	if(!contains_text(result, "searchprice=")) {
		print("Searching mall failed.");
		return 0;
	}
	
	// parse the result
	int start = index_of(result, "searchprice=") + 12;
	int end = start;
	while(contains_text("0123456789", substring(result, end, end+1)))
		end = end + 1;
	return to_int(substring(result, start, end));
}

item best_thing(int[item] prices)
{
	item best;
	foreach thing in prices {
		if(prices[thing] > prices[best])
			best = thing;
	}
	return best;
}

int best_price(int[item] prices)
{
	item best;
	foreach thing in prices {
		if(prices[thing] > prices[best])
			best = thing;
	}
	return prices[best];
}

void main() 
{
	// Build 10 of whatever Nash Crosby's Still product costs most in the 
	// mall and then sell it
	print("Using Nash Crosby's Still for monetary gain...");
	if(stills_available() > 0) {
		int[item] prices;
		// Initialize the map with keys
		prices[$item[bottle of Calcutta Emerald]] = 0;
		prices[$item[bottle of Lieutenant Freeman]] = 0;	
		prices[$item[bottle of Jorge Sinsonte]] = 0;
		prices[$item[bottle of Definit]] = 0;
		prices[$item[bottle of Domesticated Turkey]] = 0;
		prices[$item[boxed champagne]] = 0;
		prices[$item[tangerine]] = 0;
		prices[$item[kiwi]] = 0;
		prices[$item[cocktail onion]] = 0;
		prices[$item[kumquat]] = 0;
		prices[$item[tonic water]] = 0;
		prices[$item[raspberry]] = 0;
	
		int number;
		foreach thing in prices
			prices[thing] = get_cheapest_mall_price(thing);
	
		while(stills_available() > 0 && count(prices) > 0) {
			item thing = best_thing(prices);
			int price = best_price(prices);
			int number = creatable_amount(thing);
			if(!create(number, thing)) {
				print("Could not create still item.");
				break;
			}
			put_shop(price - 1, 0, thing);
			remove prices[thing];
		}	
	}
}
 

macman104

Member
It's not technically mallbotting, but due to preventing mall botting, you are not able to use those URLs. I'm not aware of anyway to bypass that.
 

Ptomato

New member
I didn't necessarily mean bypassing it (I guess it's there for a reason) but doing the same thing with, say, any CLI commands or functions I may have overlooked.

How about a message printed to the console when you try a disallowed URL in visit_url() explaining that you can't do that? The blank return value had me puzzled for quite a while...
 
Top