help with my drinking script

razorboy

Member
I'd like some comments on my drinking script. It works ok most of the time, although when my bartender breaks it freaks out. So I'd like to fix that.

I recently added the counter to check for lack of ingredients... and it quits fine, but I'm not sure why the "create" doesn't always work. Sometimes it will buy the ingredients and sometimes not. I wonder if that's a mall cost limit issue?

Anyways, here's my script, please comment!

Code:
int x = 0;
repeat {
        foreach drink in $items[sangria del diablo, cherry bomb, dirty martini, vesper, bodyslam, grogtini] {
           if (available_amount(drink) + creatable_amount(drink) > 0) {
        	   if (inebriety_limit() - my_inebriety() <= 1){
	         	print("drink limit reached, breaking", "red");
		        break;
	           }
	           else{
	                print("I have ingredients to drink 1 "+ drink, "green");
                    boolean success = create(1, drink);
					if (success){
						drink(1, drink);
						}
					else{
						print("I failed to make "+ drink);
						break;
						}
	           }
           }
           else{
                print("I don't have ingredients to drink "+ drink, "red");
				x = x + 1;
           }
       }
} until ((inebriety_limit() - my_inebriety() <= 1) || (x == 6));

if (x == 6) {
	print("you are out of everything", "red");
 
Last edited:

slyz

Developer
If you don't have enough ingredients on-hand, creatable_amount() will return 0 and it will skip the drink completely.

Also, if you happen to have one of the drinks on hand, and you ask Mafia to create it, it will try to buy a TPS, so that would probably raise the mall cost limit issue. Since you check for available_amount(), check if you already have the drink before creating one.
 
Last edited:

Bale

Minion
Also, if you happen to have one of the drinks on hand, and you ask Mafia to create it, it will try to buy a TPS, so that would probably raise the mall cost limit issue.

That can be fixed pretty easily by changing create() to retrieve_item().


If you don't have enough ingredients on-hand, creatable_amount() will return 0 and it will skip the drink completely.

This is the big issue. It's doing nothing if you don't have the ingredients on hand. I'd suggest you simply check if one is available or createable. If so, retrieve_item() on it, but if it fails, then you need to check prices of lemons, olives and cherries to decide which you want to create.
 

razorboy

Member
Thanks for the comments, guys.

I do see an issue... at least with how I'm thinking of implementing your ideas. I don't think I can put the mall purchase bit in the recursion, because then it will simply stop at the first drink and buy ingredients for it, if they aren't available. I want the first pass through the recursion to check if there is an item that is craftable (or drinkable) with what I have on-hand.

I'm guessing what I could do is turn this into a function and at the
if (x == 6) {
print("you are out of everything", "red");

section, I could do the mall-purchase section, and then call the function again. Although I sense a crazy endless loop in the making.
 

Bale

Minion
If your loop is endless, then you haven't adequately defined the end condition. Post what you have and we'll offer help.
 
Top