I refined my above code to work, instead of just suggesting what to you. I replaced your default statement about mining with this:
When I tested the logic back and forth with different numbers, it worked, so I'll be running it in my copy. Feel free to add it to yours as well.
That should work, one issue you might run into is if you start the script at molds + 79 nuggets then by the end you could have way more then molds + 80 nuggets. Its one of the reasons I haven't provided an update with something like this there are a bunch of cases that could work, just none I'm totally thrilled with.
I would suggest two things, and is the way I'm leaning right now.
Keep your int maxExtraNuggets = X;
But move the conditional statement into then top of the handleCurrentMine() function.
Also move :
Code:
if (mineOnlyPeppermints) {
if (minNumberTailingsPerCave < 12) {
print("You have selected to only mine peppermints, but the min number of peppermints is quite low, setting min number ot peppermints to a higher number to reduce kol server load of getting new cave walls.", "red");
minNumberTailingsPerCave = 20;
}
maxFailsAllowed = 5;//If only mining peppermints all caves are valid.
}
Into the handleCurrentMine() function
So top of handleCurrentMine() should look like:
Code:
void handleCurrentMine() {
if ( item_amount( $ item[nugget of crimbonium] ) > (( item_amount( $ item[cylindrical mold])) + maxExtraNuggets)){
mineOnlyPeppermints = true;
} else { mineOnlyPeppermints = false; }
if (mineOnlyPeppermints) {
if (minNumberTailingsPerCave < 12) {
print("You have selected to only mine peppermints, but the min number of peppermints is quite low, setting min number ot peppermints to a higher number to reduce kol server load of getting new cave walls.", "red");
minNumberTailingsPerCave = 20;
}
maxFailsAllowed = 5;//If only mining peppermints all caves are valid.
}
if (have_effect($effect[Crimbonar]) == 0 && have_effect($effect[object detection]) == 0) { <rest of function>
This will make it so at most after running the script you will have a max of molds + maxExtraNuggets + 5 nuggets