eating and drinking for breakfast

mhopkins321

New member
Hey all,

I'd first like to start out by saying I know nothing about scripting for mafia. I'm assuming this has probably already been implemented in a script somewhere but I'm not entirely sure what I'm looking for or how to search for it.

I'm looking for something that will eat and drink specific items (hi meins and dusty bottles) upon logging in. This is for my meat farming toons. I always have these items on hand and it'd save some clicking if they would automatically eat three times, and drink 9 times.

Thanks
-Mike
 

StDoodle

Minion
What you need to do is first come up with a script that does everything you want. It doesn't have to be ash; a simple text file will work if all you need is really basic stuff. If you know how to do what you want on the CLI, just pretend your script was the CLI (put one command on each line) and it should work fine. For example:
Code:
use 1 milk of magnesium
eat 3 spooky hi mein
shrug madrigal
cast ode to booze
drink 3 dusty bottle great
should work (I'm not 100% sure of the dusty bottle syntax to be flexible for multiple configurations; if you don't plan on ascending with this script in place, it becomes simpler still).

Then, once the script is done, go to the General menu, select Preferences, and go to the Breakfast tab. There's a button to select a file for "On login" that you'll use to get a file-browser. Locate your script, and it will be all set to run each time you login.

If you log on more than once per day, it might be worth doing in ash so that you can check to see if the script has been run yet. One helpful hint is that any custom-made preference that starts with an underscore is reset to a blank string the first time you log in each day. So, if you create a preference named "_myCustomBreakfastCheck" you can set it to true (or anything, really) when the script runs, and make checking that it's blank a condition of running.
 

Winterbay

Active member
I think this does what you want (and is probably overcomplicated, but since it is my first attempt at a script... :))
ANy comments from more experienced ash-coders are very welcome...

Code:
void main(){
item good_bottle;
int hot = item_amount(to_item(1592));
int cold = item_amount(to_item(1593));
int spooky = item_amount(to_item(1594));
int stinky = item_amount(to_item(1595));
int sleazy = item_amount(to_item(1596));

if ((hot+cold+spooky+stinky+sleazy) < 3)
{
	print("You don't have enough hi meins");
	abort();
}

while (my_fullness() < (fullness_limit() -4))
{
	if(hot>0)
	{
		eat(1, $item[hot hi mein]);
		hot = hot -1;
	}
	if(cold>0)
	{
		eat(1, $item[cold hi mein]);
		cold = cold -1;
	}
	if(spooky>0)
	{
		eat(1, $item[spooky hi mein]);
		spooky = spooky - 1;
	}
	if(stinky >0)
	{
		eat(1, $item[stinky hi mein]);
		stinky = stinky -1;
	}
	if(sleazy >0)
	{
		eat(1, $item[sleazy hi mein]);
		sleazy = sleazy -1;
	}
}

for m from 2271 to 2276
{
	if(get_property("lastDustyBottle" + to_string(m)) == 4)
	{
		while (my_inebriety() < (inebriety_limit() - 2))
		{
			good_bottle = to_item(m);
			drink(1, good_bottle);
		}
	}
	else
	{
		print("You're too drunk already");
		abort();
	}
}
}
 

StDoodle

Minion
Most of Winterbay's script looks good. I would recommend a check for milk & ode, since you'll get the pop-up warning without (or switch to eatsilent() & overdrink() instead if you don't care about these, as well as a check for whether or not the script has been run yet today.

Also -- and this came up yesterday in a different context -- is there a quick way to check how many AT songs one currently has active? Would be nice for situations such as this, when one would like to cast Ode. For the time being, I simply have a function that returns the amount of songs in one's head, by checking every single one, but this seems clunky and I'm sure I missed something.
 

Veracity

Developer
Staff member
Rather than:

int hot = item_amount(to_item(1592));

why not use:

int hot = item_amount( $item[ hot hi mein ] );

?

Advantages:

- you don't have to look up item numbers
- you can't accidentally enter the wrong item number
- it's much more readable by a human
- it is faster to execute, at the expense of being marginally slower to compile
 

Winterbay

Active member
Rather than:

int hot = item_amount(to_item(1592));

why not use:

int hot = item_amount( $item[ hot hi mein ] );

?

I think that was mainly a rest from when I had an idea to iterate over the different hi meins and would thus have a for-loop with the item number in it. Since I scrapped that idea I should probably have changed that as well :)
 

Bale

Minion
One more suggestion is that the script should compare my_fullness() to fullness_limit() and compare my_inebriety() to inebriety_limit(). That way it won't bork anything if he logs in twice in the same day.
 

mhopkins321

New member
Is the eat drink script actually cost effective or does it just get as many turns as possible? Yes, those are two different things, especially to somebody who is a meat farmer
 

slyz

Developer
From what I gathered, it works like Houeland's diet page: it keeps considering better options until getting 1 more adv would cost more than the value of an adventure (I think the mafia preference is used).
 

Winterbay

Active member
You can set the value of one adventure somehow as well. The Farm.ash script does that so that eatdrink uses the value of the optimum adventure from farm.ash.
 
Top