Maps: "foreach" until satisfied..?

hippymon

Member
I am wondering if there is anyway for one to go throw a map and stop after "conditions" are satisfied (conditions being personal goal, not KoLmafia conditions)? For example:
Code:
	item [int] famitem;
	famitem[0] = $item[lucky Tam O'Shanter];
	famitem[1] = $item[lucky Tam O'Shatner];
	famitem[2] = $item[miniature gravy-covered maypole];
	famitem[3] = $item[plastic pumpkin bucket];
	famitem[4] = $item[Mayflower bouquet];
	famitem[5] = $item[wax lips];
	famitem[6] = $item[flaming familiar doppelgänger];
	famitem[7] = $item[ant hoe];
	famitem[8] = $item[ant pick];
	famitem[9] = $item[ant pitchfork];
	famitem[10] = $item[ant rake];
	famitem[11] = $item[ant sickle];
	famitem[12] = familiar_equipment(my_familiar());
	#It should run through each item in the above map until
	#One of the items are found. At which time it will stop running.
	foreach i in famitem
		if(got_item(famitem[i]))
			equip(famitem[i]);
But do so without putting this in a "void/boolean fam_equipment()" and using "return". Anyone know?
 
If kolmafia doesn't support break...I think it does, this just popped into my mind.
Code:
	item [int] famitem;
	famitem[12] = $item[lucky Tam O'Shanter];
	famitem[11] = $item[lucky Tam O'Shatner];
	famitem[10] = $item[miniature gravy-covered maypole];
	famitem[9] = $item[plastic pumpkin bucket];
	famitem[8] = $item[Mayflower bouquet];
	famitem[7] = $item[wax lips];
	famitem[6] = $item[flaming familiar doppelgänger];
	famitem[5] = $item[ant hoe];
	famitem[4] = $item[ant pick];
	famitem[3] = $item[ant pitchfork];
	famitem[2] = $item[ant rake];
	famitem[1] = $item[ant sickle];
	famitem[0] = familiar_equipment(my_familiar());
	#It should run through each item in the above map until
	#One of the items are found. At which time it will stop running.
        item toequip;
	foreach i in famitem
		if(got_item(famitem[i]))
                    toequip = famitem[i];
	equip(famitem[i]);

The order of the items is reversed to maintain seek order (the last one found is the one that is equipped instead of the first).

Break is probably better speed wise, but I don't think you will notice a difference.
 
Top