What did I do wrong here?

Code:
//Drink 3 Neuromancers
if (item_amount ($item[Neuromancer]) >= 3 && DrunkLeft >= 12)
drink (3, $item[Neuromancer] );
else {
if (!user_confirm("Not enough Neuromancers want to buy "+(floor((DrunkLeft) / 4) - item_amount ($item[mandarina colada]))+" @ "+ ((floor((DrunkLeft) / 4) - item_amount ($item[mandarina colada])) * mall_price($item[mandarina colada]) )+"" ))
{
   abort("CHEAP!");
}
  drink (floor((DrunkLeft) / 4), $item[Neuromancer] );
}




//Drink 1 dry martini
if (item_amount ($item[dry martini]) >= 1 && DrunkLeft >= 3)
drink (1, $item[dry martini] );
else {
if (!user_confirm("Not enough Martinis want to buy "+(floor((DrunkLeft) / 2) - item_amount ($item[dry martini]))+" @ "+ ((floor((DrunkLeft) / 2) - item_amount ($item[dry martini])) * mall_price($item[dry martini]) )+"" ))
{
   abort("CHEAP!");
}
  drink (floor((DrunkLeft) / 3), $item[dry martini] );
}

This was an attempt to alter a bit of code written by Icon so that it would drink 4 Neuromancers and 1 Dry Martini instead of 4 mandarina coladas and a dusty bottle of port. For some reason it tries to buy up 9 Dry Martinis instead of the one I want it to drink.

Here is the original section of code.

Code:
//Drink 3 Mandarina Coladas
if (item_amount ($item[mandarina colada]) >= 3 && DrunkLeft >= 12)
drink (3, $item[mandarina colada] );
else {
if (!user_confirm("Not enough Coladas want to buy "+(floor((DrunkLeft) / 4) - item_amount ($item[mandarina colada]))+" @ "+ ((floor((DrunkLeft) / 4) - item_amount ($item[mandarina colada])) * mall_price($item[mandarina colada]) )+"" ))
{
   abort("CHEAP!");
}
  drink (floor((DrunkLeft) / 4), $item[mandarina colada] );
}




//Drink 1 Port
if (item_amount ($item[dusty bottle of Port]) >= 1 && DrunkLeft >= 2)
drink (1, $item[dusty bottle of Port] );
else {
if (!user_confirm("Not enough Ports want to buy "+(floor((DrunkLeft) / 2) - item_amount ($item[dusty bottle of Port]))+" @ "+ ((floor((DrunkLeft) / 2) - item_amount ($item[dusty bottle of Port])) * mall_price($item[dusty bottle of Port]) )+"" ))
{
   abort("CHEAP!");
}
  drink (floor((DrunkLeft) / 2), $item[dusty bottle of Port] );
}

And I've just noticed I apparently have it drinking 3 not 4 Neuromancers. I changed the numbers under DrunkLeft from the 2 in the original code to 3 because I thought I was correcting for the difference in Drunk between a Dry Martini and Port. Is that the cause for trying to buy 9 of them? If I change them back to a 2 will it work right?

Edit: Changed the numbers back and it still wants to buy 9 Dry Martinis but actually only buys 2 if I answer yes. Then it asks if I really want to overdrink. If I say no it drinks neither and continues on to the rest of the script. How can I get it to buy and drink ONE Dry martini like I want it to so it puts my Drunkenness to 19?
 
Last edited:

Winterbay

Active member
How is DrunkLeft calculated? If that isn't updated between the two if-statements then I guess that could be the problem.
 

Theraze

Active member
Yeah... instead of using a possibly undefined int, better to do (inebriety_limit() - my_inebriety()) or something like that... should always give you an accurate amount of drunk remaining.

That actually updates as you drink.
 
Yeah... instead of using a possibly undefined int, better to do (inebriety_limit() - my_inebriety()) or something like that... should always give you an accurate amount of drunk remaining.

That actually updates as you drink.

Thanks, I'll try that see if it works.

Edit: Gah, I give up. I replaced the whole eat drink spleen section with cli_execute ("eatdrink") I hope the bugs are worked out of eatdrink.ash.
 
Last edited:

Theraze

Active member
Unfortunately, eatdrink still requires information given to it... try adding something like this to your code, anywhere (just make sure importing happens before the eatdrink, and sim_consume is between them):
Code:
import <EatDrink.ash>;
SIM_CONSUME=false;
eatdrink(fullness_limit(), inebriety_limit(), spleen_limit(), false);
 
Unfortunately, eatdrink still requires information given to it... try adding something like this to your code, anywhere (just make sure importing happens before the eatdrink, and sim_consume is between them):
Code:
import <EatDrink.ash>;
SIM_CONSUME=false;
eatdrink(fullness_limit(), inebriety_limit(), spleen_limit(), false);

Inputting the information isn't a big issue for me. Ran the script calling eatdrink.ash and it worked as intended. Although somehow my adventure value dropped back to 500 but I have that fixed.
 

Winterbay

Active member
There is a longer version of eatdrink() as well:
Code:
void eatdrink(int foodMax, int drinkMax, int spleenMax, boolean overdrink, int advmeat, int primemeat, int offmeat, int pullmeat,boolean sim)
Where the last parts are the value of an adventure, the cost of main stat and offstat respectively as well as the cost to pull an item. And last the sim_consume setting (so no need to set that one if you use this version of the function)
 

Theraze

Active member
True, you can use the fully overloaded edition... I just use the lazy version as my normal food alias. Well, when fortune cookie counters permit. If fortune cookies are planned, I use eatdrinkne (no eating). When alcohol is expected from random adventuring, eatdrinknd (no drink). End of day, eatdrinkod (overdrink, or overdose, depending on my mood). Someday I should really complicate things though and make advmeat be based on my level. :D
 

Winterbay

Active member
Yeah, my aliases use the long version because I like to give it a value_of_adventure number. (the similar things to yours are eater, drinker and eatdrink+ for overdrinking.)
 
Top