Script request: Display brewery info

rendar55

New member
This is a script that I'd like to add to my current breakfast script. I want it to display what today's brewery special is, the cost, and the adventures gained from consuming it with ode active. There's more functionality I want to add to it (as well as making it work at Cheez Snootee), but I'll probably add that myself later. I mostly just can't figure out how to pull that info from data files, or wherever is easiest. All help is appreciated.
 

heeheehee

Developer
Staff member
daily_special() might be of use to you. Specifically,
PHP:
if(in_mysticality_sign() || in_moxie_sign()) {
    print("Daily special today: "+daily_special());
    print("Price: "+3*autosell_price(daily_special()));
}

The only point not addressed so far is the adventure gain, but that's because I'd have to file_to_map booze.txt, and I'll let you figure that one out (EatDrink might be a nice reference point).
 
Wow, old thread. :/

When r9990 rolled, I thought of a question. Is there a way to check adventure gain of booze from brewery (or food from the restaurant) with ode/milk active in an ash script? And ultimately, check advgain from what I am going to drink against the brewery and drink from brewery if it is better.

Something like if (drink_adv_gain>4.25) { choose drink from brewery or a list of booze I give it.}
 

slyz

Developer
Are brewery/restaurant consumables affected by Ode/Milk now?

Anyway, here is something that will return the average adventure yield.
PHP:
float get_avg( string range )
{
	string[int] split_range = split_string(range, "-");
	if ( split_range.count() == 1 ) return split_range[0].to_float() ;
	return ( split_range[0].to_int() + split_range[1].to_int() ) / 2.0 ;
}

float get_num_adv( item itm, boolean withEffect )
{
	return itm.adventures.get_avg() + ( withEffect ? itm.fullness + itm.inebriety : 0.0 );
}

item it;

it = $item[ rockin' wagon ];
it.get_num_adv( true ).print();

it = $item[ hell ramen ];
it.get_num_adv( true ).print();

daily_special().get_num_adv( false ).print();
Simply call
PHP:
get_num_adv( item, true )
if you want to add the adventures added by Ode/Milk, and
PHP:
get_num_adv( item, false )
otherwise.
 
Last edited:
Thanks for the informative script! ^^ I do believe that the daily special food/booze are affected by milk/ode.
However, a few questions, being a copy/paste person with no knowledge of ASH..
1) What do you mean when you say "simply call". I know what it means to call a script, but not when used in this case.
2) was going to ask how to drink the special in an ash script but was answered in KoL chat. ^^
3) Your "get_num_adv( item, true )" seems to add the advs by milk/ode. Not the "false" option. I think? (Figures from running it in mafia seems to point it out.)

I had another question but it seemed to have grown wings and flown away. O_O
 

slyz

Developer
1) What do you mean when you say "simply call". I know what it means to call a script, but not when used in this case.
In a script, you can use Mafia's pre-defined functions like eat() or drink(), but you can also define your own functions, like this:
PHP:
outputType functionName( parameterType parameter1, parameterType parameter2 )
{
     // do stuff
     return output;
}
and later on you can use that function ('call' it) like any other.
In you example:
Code:
if (drink_adv_gain>4.25) { choose drink from brewery or a list of booze I give it.}
I'm guessing that you want the number of adventures per fullness/drunkness, so I'm going to define another function, get_adv_per_full(), that takes the total adventure yield and divides it by the fullness/drunkness.
Since you always want to count in Ode/Milk, I changed get_num_adv() so it always counts the extra adventures.

Then, you can use that function in your script to take your decision:
PHP:
float get_avg( string range ) 
{ 
	string[int] split_range = split_string(range, "-"); 
	if ( split_range.count() == 1 ) return split_range[0].to_float() ; 
	return ( split_range[0].to_int() + split_range[1].to_int() ) / 2.0 ; 
} 

float get_num_adv( item itm ) 
{ 
	return itm.adventures.get_avg() + itm.fullness + itm.inebriety; 
}

float get_adv_per_full( item itm ) 
{ 
	return itm.get_num_adv() / ( itm.fullness + itm.inebriety ); 
}

if ( get_num_adv( daily_special() ) > 4.25 )
{
	// choose drink from brewery or a list of booze I give it.
}

To understand the code above, I think you need 2 bits of information:

1) this:
PHP:
item it;
it.get_num_adv();
is the same as:
PHP:
item it;
get_num_adv( it );
It's just two ways of writing the same thing.

2) Here
PHP:
item it;
it.adventures;
"adventures" is not a function, it's a "proxy value". In ASH, several types of constants have proxy values attached to them. You can see what I mean by typing "ash $item[ hell ramen ]" in the gCLI.

If you want to learn some more about all this, I'd suggest you go visit the Mafia Wiki:
- ASH For Beginners
- Proxy Records
 
Sweet, thanks for the information! I've put it in my script and made the necessary adjustments. Cant wait to test this out when the brewery has the relevant booze. :D
 
Top