If(item_amount($item[Knob sausage chow mein]) < 1)
{
if(!confirm("buy 1 knob sausage chow mein?"))
{
if(!confirm("eat 1 bat wing chow mein?"))
{
if(!confirm("eat 1 rat appendix chow mein?"))
{
cli_execute("abort out of choices");
}
else
{
If(item_amount($item[rat appendix chow mein]) < 1)
{
if(!confirm("buy 1 rat appendix chow mein?"))
{
cli_execute("abort unable to eat");
}
else
{
buy(1, $item[rat appendix chow mein]);
return eat(1, $item[rat appendix chow mein]);
}
}
}
}
else
{
If(item_amount($item[bat wing chow mein]) < 1)
{
if(!confirm("buy 1 bat wing chow mein?"))
{
cli_execute("abort unable to eat");
}
else
{
buy(1, $item[bat wing chow mein]);
return eat(1, $item[bat wing chow mein]);
}
}
}
}
else
{
buy(1, $item[Knob sausage chow mein]);
return eat(1, $item[Knob sausage chow mein]);
}
}
int a = select("choose a chow mein", "knob sausage, bat wing, rat appendix");
item choicefood;
if(a==0)
{choicefood = $item[knob sausage chow mein]}
else
{
if(a==1)
{choicefood = $item[bat wing chow mein]}
else
{choicefood = $item[rat appendix chow mein]}
}
if(item_amount(choicefood) < 1)
{
if(confirm("buy a " + choicefood + "?"))
{
buy(1, choicefood)
}
else
{
cli_execute("abort cannot eat a " + choicefood);
}
}
eat(1, choicefood);
boolean ate_something = false;
void try_eat( item food )
{
if ( ate_something )
return;
if ( !user_confirm( "eat 1 " + food + "?" ) )
return;
if ( food.item_amount() == 0 )
if ( !user_confirm( "buy 1 " + food + "?" ) )
abort( "cannot eat a " + food + "." );
eat( 1, food );
ate_something = true;
}
void main()
{
try_eat( $item[knob sausage chow mein] );
try_eat( $item[bat wing chow mein] );
try_eat( $item[rat appendix chow mein] );
if ( !ate_something )
abort( "Could not eat anything." );
}
Unless I'm missing something, the primary motivation for not including user prompting for anything other than booleans is just as problematic now as it was two years ago.
I think user_confirm was only added because I could sympathize with the idea of using it to abort a script. If it's frustrating to feel limited by it, I'd feel more comfortable removing it entirely than I would by adding more things that'd lead to "Ok, so KoLmafia suddenly locked up..." bug reports.
Please input value for int amount
>1
Please input value for float factor
>1
Please input value for int iterations
>1
Please input value for int chain_count
>1
Betting 1 meat from inventory
You must bet at least 1,000 meat.
Bet 1/1/1: for 1 Meat -> FAILED
Chain 1 failed on iteration #1 placing bet for 1
Done running 1 chains of 1 bets.
Net winnings = 0. Net change to closet = 0
How much meat would you like to bet?
>1
You must bet at least 1,000 meat.
How much meat would you like to bet?
>1000
etc.
public void focusGained(FocusEvent e) {
if getOwnedWindows.length >= 1 {
getOwnedWindows(1).toFront();
}
}
main(string what_to_devour|"Which food item would you like to devour?") {
Giving scripts free reign to prompt while you're alt-tabbed is probably asking for trouble.
...
Any solutions, or will we keep getting the same old, "BUT THIS IS HOW I'D USE IT" arguments that I kept getting two years ago?
I like user-confirms and vote in favor of one that can accept a string.
... THIS IS HOW I'D USE IT ...
But again, you don't have to use them in your scripts if you oppose them.
I just don't like having to edit a .txt file every time I run a script. For that reason I have resisted using Z's vars for my item handling scripts.