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 )
{
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 )
{
}
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
"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