Parsing Concoctions

fronobulax

Developer
Staff member
Does anyone have any scripts that are parsing concoctions.txt that they might share or remind me that they are already being shared?

I'm a Display Case completionist and it appears that there are items that cannot be purchased from the Mall in completed form but all of the components can be obtained. So my immediate goal is a function that takes an item as input and returns a list of "atomic" components required to assemble the item plus the skills required. get_ingredients doesn't quite do the job because it doesn't tell me the skill, returns the predecessor ingredients (not the "atomic" ones) and (according to the Wiki) "Returns an empty map for items that cannot be created at the moment" which means I can't use it for planning purposes.

I figure this is really just an exercise in repackaging what is in concoctions but if I actually have to parse it myself I might propose and write an ash function (or functions) instead. get_raw_ingredients and get_required_creation_skills might be the result.
 

Fluxxdog

Active member
I considered it for my Superdrinks script, but I found that using get_ingredients tended to work better without hard coding too much.

Another library of mine has this method:
Code:
int[item]get_grocery_list(item dish){ int[item]grocery;
	foreach cut,piece in get_ingredients(dish){
		int need=piece-available_amount(cut)-([COLOR="#FF0000"]prop_flag[/COLOR]("autoSatisfyWithStash")?stash_amount(cut):0);
		switch{
		case need<=0: break;
		case cut==$item[wad of dough]:
		case cut==$item[flat dough]:
		case count(get_ingredients(cut))==0: grocery[cut]+=need; break;
		default: foreach refine,taste in get_grocery_list(cut) grocery[refine]+=taste*need;
		}
	}
	return grocery;
}
int[item]get_grocery_list(boolean[item]dishes){ int[item]grocery;
	foreach dish in dishes foreach cut,piece in get_grocery_list(dish) grocery[cut]+=piece;
	return grocery;
}
prop_flag(string) converts the named preference to a boolean. The int[item] map returned tells you how much of what you need to make said item or items if you use the second method.
 
Top