Rainbow Gravitation made easy

Using r10873 I'm getting an odd message when I run this script.

Code:
WARNING: Missing return values in boolean functions will soon become an error (rainbow.ash, line 21)

Currently the script still runs correctly. Now, as far as I can tell line 21 is

Code:
}

So I'm not sure what return values it wants me to add. I do not recall making any changes to the base script but I'm including the entire script in case I've forgotten changing an argument or two that is causing the problems now. If it makes a difference I'm running the script by typing the script name into my CLI.

Code:
// Script: Rainbow Gravitation v 1.5
// Author: Bale
// This will create a prismatic wad by transmuting elemental wads, if it can be done in Hardcore.
script "Rainbow Gravitation.ash";
notify <Bale>;

item [item] to_make;
to_make [$item[cold wad]] = $item[hot wad];
to_make [$item[spooky wad]] = $item[cold wad];
to_make [$item[stench wad]] = $item[spooky wad];
to_make [$item[sleaze wad]] = $item[stench wad];
to_make [$item[hot wad]] = $item[sleaze wad];

boolean mall = can_interact() && get_property("autoSatisfyWithMall").to_boolean();

// Mafia doesn't have recipes for cooking wads so I need to use visit_url()
boolean cook_wad(item it) {
	print("Cooking a twinkly wad with a "+ it+ ".");
	//visit_url("craft.php?mode=cook&action=craft&a=1450&b="+ to_string(it.to_int())+ "&qty=1&master=Bake%21&pwd");
	craft("cook", 1, $item[twinkly wad], it);
}

// Transform all wads necessary to cast the skill.
void transform_wads() {
	item [item] transmute;
	foreach key in to_make
		transmute[to_make[key]] = key;
	item choice;
	foreach key in to_make
		if(item_amount(key) < 1) {
			choice = to_make[key];
			while(item_amount(choice) < 2) {
				choice = to_make[choice];
			}
			while(item_amount(key) < 1) {
				// create(1, transmute[choice]);
				cook_wad(choice);
				choice = transmute[choice];
			}
		}
}

// Figure out the cost of transmutation, then cast Rainbow Gravitation
boolean gravitate() {
	int [item] wads;
	wads[$item[twinkly wad]] = item_amount($item[twinkly wad]);
	wads[$item[hot wad]] = item_amount($item[hot wad]);
	wads[$item[cold wad]] = item_amount($item[cold wad]);
	wads[$item[spooky wad]] = item_amount($item[spooky wad]);
	wads[$item[stench wad]] = item_amount($item[stench wad]);
	wads[$item[sleaze wad]] = item_amount($item[sleaze wad]);
	
	boolean doit = true;

	// Do I have one of every wad? If so, then ask for confirmation if transformation is needed and cast.
	boolean rainbow(){
		foreach key in to_make
			if(wads[key] < 1)
				return false;
		int twinkle_used = item_amount($item[twinkly wad]) - wads[$item[twinkly wad]];
		if(twinkle_used > 0)
			doit = user_confirm("Transmuting elemental wads would use up "+ twinkle_used+ " twinkly wads.\nGravitate the Rainbow?");
		if(doit) {
			transform_wads();
			use_skill(1, $skill[Rainbow Gravitation]);
		}
		return true;
	}
	
	if(mall) {
		int summonsLeft = 3 - get_property("prismaticSummons").to_int();
		foreach key in wads
			retrieve_item(summonsLeft, key);
		use_skill(summonsLeft, $skill[rainbow gravitation]);
		return true;
	}
	item change;
	int steps;
	foreach key in to_make
		if(wads[key] < 1) {
			change = to_make[key];
			steps = 1;
			while(wads[change] < 2) {
				change = to_make[change];
				steps = steps + 1;
			}
			wads[key] = wads[key] + 1;
			wads[change] = wads[change] - 1;
			wads[$item[twinkly wad]] = wads[$item[twinkly wad]] - steps;
			if(wads[$item[twinkly wad]] < 1) {
				print("There are insufficent twinkly wads to transmute that many elemental wads", "red");
				return false;
			}
			if(rainbow())
				return doit;
		}
		if(rainbow())
			return doit;
	return false;
}

// Can't transmute wads without Way of the Sauce
boolean need_way() {
	boolean need = false;
	foreach key in to_make
		if(item_amount(key) < 1) {
			print("You lack a "+ to_string(key)+ ".", "#FF7028");
			need = true;
		}
	if(need && !have_skill($skill[The Way of Sauce]))
		return true;
	return false;
}

// First, do I have the pre-requisites to cast Rainbow Gravitation?
boolean can_gravity() {

	int el_wad;
	int el_wads(){
		foreach key in to_make
			el_wad = el_wad + item_amount(key);
		return el_wad;
	}

	switch {
	case !have_skill($skill[Rainbow Gravitation]):
		print("You don't have the skill to gravitate a rainbow.", "red");
		return false;
	case get_property("prismaticSummons").to_int() > 2:
		print("You've already made 3 Rainbow Wads today!", "red");
		return false;
	case mall:
		return true;
	case el_wads() < 5:
		print("There are insufficient elemental wads. Make "+ to_string(5 - el_wad) + " more, then try again.", "red");
		return false;
	case item_amount($item[twinkly wad]) < 1:
		print("You cannot use Rainbow Gravitation without a twinky wad.", "red");
		return false;
	case need_way():
		print("Without understanding the Way of the Sauce you cannot transmute wads.", "red");
		return false;
	default:
		return true;
	}
}

void main() {
	if(can_gravity())
		gravitate();
}
 
The cook_wad function doesn't return either true or false, but it's officially a boolean return. Best thing is to just turn the craft line into:
Code:
	return to_boolean(craft("cook", 1, $item[twinkly wad], it));
 
This is because of a fairly recent change to KoLmafia. I haven't been using this script lately since I can't use it in Boris so I hadn't noticed. It's easy to fix. I've done so and uploaded it to the first post. The problem was that a boolean function now needs to always return a boolean value.

Thanks for telling me about the problem. I appreciate it.
 
This is because of a fairly recent change to KoLmafia. I haven't been using this script lately since I can't use it in Boris so I hadn't noticed. It's easy to fix. I've done so and uploaded it to the first post. The problem was that a boolean function now needs to always return a boolean value.

Thanks for telling me about the problem. I appreciate it.

I have been using this in aftercore, after finishing my boris/zombie/etc runs. I have run it more than 90 times so if you count that, it's paid off already. Thanks for writing it!

I have learned to just ignore the boolean function warning.
 
I'm pretty sure that back in April I updated the script to fix that warning. Please download the newer version.
 
Is that easier than (trivially) fixing the bug in code so that the warning does not appear?
Well, perhaps it is easier - but is it better?

As a developer - it's easier to fix the code.

As a user - I can't control what the developer does. And ever since I got a "smart" phone, the endless parade of updates is wearying. So it's easier to ignore the warning than check if the developer has released a new version.
 
Back
Top