How do I eat sushi with a script?

Bale

Minion
Something isn't working properly for me with regards to sushi. Here's my output. The most important part is the very last line so feel free to skip to that:
Code:
Searching for "beefy fish meat"...
Searching for "glistening fish meat"...
Searching for "slick fish meat"...
Searching for "sea avocado"...
Searching for "sea carrot"...
Searching for "sea cucumber"...
Searching for "sea radish"...
Searching for "white rice"...
Purchasing white rice (1 @ 4,300)...
You acquire an item: white rice
Purchasing white rice (5 @ 4,300)...
You acquire white rice (5)
Purchases complete.
Using cached search results for sea carrot...
Purchasing sea carrot (2 @ 4,850)...
You acquire sea carrot (2)
Purchasing sea carrot (4 @ 4,850)...
You acquire sea carrot (4)
Purchases complete.
Using cached search results for slick fish meat...
Purchasing slick fish meat (6 @ 8,557)...
You acquire slick fish meat (6)
Purchases complete.
Searching for "seaweed"...
Purchasing seaweed (4 @ 5,000)...
You acquire seaweed (4)
Purchasing seaweed (2 @ 5,000)...
You acquire seaweed (2)
Purchases complete.
Verifying ingredients for sneaky rabbit roll (1)...
Creating/consuming sneaky rabbit roll (1 of 1)...
You gain 13 Adventures
You acquire an effect: Fishy (duration: 55 Adventures)
You gain 24 Magicalness
You gain 8 Chutzpah
Verifying ingredients for sneaky rabbit roll (1)...
Creating/consuming sneaky rabbit roll (1 of 1)...
You gain 11 Adventures
You acquire an effect: Fishy (duration: 55 Adventures)
You gain 23 Enchantedness
You gain 13 Sarcasm
[COLOR="Red"]You need 1 more sneaky rabbit roll to continue.[/COLOR]

Why do I get that error message? Here's my code. I highlighted the line that causes the error message.
Code:
void eat_fish() {
	record comparison_shop {
		item it;
		int price;
	};
	comparison_shop [int] fishmeat;
	fishmeat[0].it = $item[beefy fish meat];
	fishmeat[1].it = $item[glistening fish meat];
	fishmeat[2].it = $item[slick fish meat];
	comparison_shop [int] veggie;
	veggie[0].it = $item[sea avocado];
	veggie[1].it = $item[sea carrot];
	veggie[2].it = $item[sea cucumber];
	veggie[3].it = $item[sea radish];
	foreach i in fishmeat
		fishmeat[i].price = mall_price(fishmeat[i].it);
	sort fishmeat by fishmeat[index].price;
	foreach i in veggie
		veggie[i].price = mall_price(veggie[i].it);
	sort veggie by veggie[index].price;
	string sushi;
	switch(veggie[0].it) {
	case $item[sea cucumber]:
		switch(fishmeat[0].it) {
		case $item[beefy fish meat]:
			sushi = "giant dragon roll";
			break;
		case $item[glistening fish meat]:
			sushi = "wise dragon roll";
			break;
		case $item[slick fish meat]:
			sushi = "tricky dragon roll";
			break;
		}
		break;
	case $item[sea carrot]:
		switch(fishmeat[0].it) {
		case $item[beefy fish meat]:
			sushi = "musclebound rabbit roll";
			break;
		case $item[glistening fish meat]:
			sushi = "white rabbit roll";
			break;
		case $item[slick fish meat]:
			sushi = "sneaky rabbit roll";
			break;
		}
		break;
	case $item[sea avocado]:
		switch(fishmeat[0].it) {
		case $item[beefy fish meat]:
			sushi = "python roll";
			break;
		case $item[glistening fish meat]:
			sushi = "ancient serpent roll";
			break;
		case $item[slick fish meat]:
			sushi = "slippery snake roll";
			break;
		}
		break;
	case $item[sea radish]:
		switch(fishmeat[0].it) {
		case $item[beefy fish meat]:
			sushi = "Jack LaLanne roll";
			break;
		case $item[glistening fish meat]:
			sushi = "wizened master roll";
			break;
		case $item[slick fish meat]:
			sushi = "eleven oceans roll";
			break;
		}
		break;
	}
	int x = floor((fullness_limit() - my_fullness())/3);
	buy(x, $item[white rice]);
	buy(x, veggie[0].it);
	buy(x, fishmeat[0].it);
	buy(x, $item[seaweed]);
	for i from 1 upto x
		[COLOR="Red"][B]cli_execute("use 1 "+ sushi);[/B][/COLOR]
}

Even trying to eat sushi from the CLI...


Code:
[COLOR="olive"]> use 1 sneaky rabbit roll[/COLOR]

Verifying ingredients for sneaky rabbit roll (1)...
Creating/consuming sneaky rabbit roll (1 of 1)...
You gain 14 Adventures
You acquire an effect: Fishy (duration: 55 Adventures)
You gain 21 Enchantedness
You gain 11 Smarm
Verifying ingredients for sneaky rabbit roll (1)...
Creating/consuming sneaky rabbit roll (1 of 1)...
You gain 11 Adventures
You acquire an effect: Fishy (duration: 55 Adventures)
You gain 21 Wizardliness
You gain 13 Sarcasm
[COLOR="Red"]You need 1 more sneaky rabbit roll to continue.[/COLOR]

I feel I should be reporting this as a bug, but I cannot believe that nobody else has ever tried to eat sushi from the command line before, so I must be missing something simple.
 

Rinn

Developer
I had to use create to eat sushi.

While we're on the subject I have a script I wrote to do automate eating the cheapest sushi as well, here it is for comparison.

Code:
  [FONT=Verdana][COLOR=Black]string [item, item] maki;

maki[ $item[beefy fish meat], $item[sea cucumber] ]            = "giant dragon roll";
maki[ $item[beefy fish meat], $item[sea carrot] ]            = "musclebound rabbit roll";
maki[ $item[beefy fish meat], $item[sea avocado] ]            = "python roll";
maki[ $item[beefy fish meat], $item[sea radish] ]            = "Jack LaLanne roll";

maki[ $item[glistening fish meat], $item[sea cucumber] ]    = "wise dragon roll ";
maki[ $item[glistening fish meat], $item[sea carrot] ]        = "white rabbit roll ";
maki[ $item[glistening fish meat], $item[sea avocado] ]        = "ancient serpent roll";
maki[ $item[glistening fish meat], $item[sea radish] ]        = "wizened master roll";

maki[ $item[slick fish meat], $item[sea cucumber] ]            = "tricky dragon roll";
maki[ $item[slick fish meat], $item[sea carrot] ]            = "sneaky rabbit roll";
maki[ $item[slick fish meat], $item[sea avocado] ]            = "slippery snake roll";
maki[ $item[slick fish meat], $item[sea radish] ]            = "eleven oceans roll";

item [int] fish;

fish[0] = $item[beefy fish meat];
fish[1] = $item[glistening fish meat];
fish[2] = $item[slick fish meat];

item [int] filling;

filling[0] = $item[sea avocado];
filling[1] = $item[sea carrot];
filling[2] = $item[sea cucumber];
filling[3] = $item[sea radish];

string [item] toppings;

toppings[ $item[none] ]                    = "";
toppings[ $item[dragonfish caviar] ]    = "magical ";
toppings[ $item[sea salt crystal] ]        = "salty ";
toppings[ $item[eel sauce] ]            = "electric ";

item [int] sake;
sake[0] = $item[berry-infused sake];
sake[1] = $item[citrus-infused sake];
sake[2] = $item[melon-infused sake];

item cheapest(item [int] items)
{
    item best = $item[none];
    int price = 999999999;

    foreach i in items
    {
        int test_price = mall_price(items[i]);
        print(items[i].to_string() + ": " + test_price.to_string());
        if (test_price < price)
        {
            price = test_price;
            best = items[i];
        }
    }

    return best;
}

void drink_sake()
{
    if (!can_drink())
    {
        print("You don't seem to be able to drink anything.", "red");
        return;
    }

    if (have_effect($effect[warm belly]) == 0)
    {
        if ( ( inebriety_limit() - my_inebriety() ) >= 4 )
        {
            print("Finding cheapest sake...", "blue");
            drink(1, cheapest(sake));
        }
        else
        {
            print("Drinking sake would make you drunk!", "red");
        }
    }
    else
    {
        print("Already under the effect of Warm Belly", "green");
    }
}

string find_cheapest_sushi(item topping)
{
    print("Finding cheapest fish...", "blue");
    item cheapest_fish = cheapest(fish);

    print("Finding cheapest filling...", "blue");
    item cheapest_filling = cheapest(filling);

    return (toppings[topping].to_string() + maki[ cheapest_fish, cheapest_filling ].to_string());
}

void eat_sushi(item topping)
{
    if (item_amount($item[sushi-rolling mat]) == 0)
    {
        abort("You need a sushi-rolling mat to roll sushi.");
    }

    if (my_fullness() > fullness_limit() - 3)
    {
        abort("You don't have enough room to eat sushi right now.");
    }

    if (my_fullness() !=0)
    {
        if (!user_confirm("It's not very optimal to eat sushi without an empty stomach, are you sure you want to continue?"))
        {
            return;
        }
    }

    drink_sake();

    if (have_effect($effect[warm belly]) == 0)
    {
        if (!user_confirm("Are you sure you want to eat sushi without warm belly?"))
        {
            return;
        }
    }
    
    string sushi = find_cheapest_sushi(topping);
    int num = (fullness_limit() - my_fullness()) / 3;

    cli_execute("create " + num.to_string() + " " + sushi);
}

void eat_sushi()
{
    eat_sushi($item[eel sauce]);
}

void main()
{
    eat_sushi();
}[/COLOR][/FONT]


I have noticed as well that a few types of sushi never get created, I submitted a bug for that a week or two ago.
 

Bale

Minion
Create, not use! Thanks! I was was sure it must be something simple like that. I also thank you for this:

Code:
maki[ $item[beefy fish meat], $item[sea cucumber] ]            = "giant dragon roll";
maki[ $item[beefy fish meat], $item[sea carrot] ]            = "musclebound rabbit roll";
maki[ $item[beefy fish meat], $item[sea avocado] ]            = "python roll";
maki[ $item[beefy fish meat], $item[sea radish] ]            = "Jack LaLanne roll";

maki[ $item[glistening fish meat], $item[sea cucumber] ]    = "wise dragon roll ";
maki[ $item[glistening fish meat], $item[sea carrot] ]        = "white rabbit roll ";
maki[ $item[glistening fish meat], $item[sea avocado] ]        = "ancient serpent roll";
maki[ $item[glistening fish meat], $item[sea radish] ]        = "wizened master roll";

maki[ $item[slick fish meat], $item[sea cucumber] ]            = "tricky dragon roll";
maki[ $item[slick fish meat], $item[sea carrot] ]            = "sneaky rabbit roll";
maki[ $item[slick fish meat], $item[sea avocado] ]            = "slippery snake roll";
maki[ $item[slick fish meat], $item[sea radish] ]            = "eleven oceans roll";
Beautiful! I wish I'd thought of that. It's so much sweeter than that mess I was using! Hopefully my revised function will work tomorrow.

Code:
void eat_fish() {
	record comparison_shop {
		item it;
		int price;
	};
	comparison_shop [int] fishmeat;
	fishmeat[0].it = $item[beefy fish meat];
	fishmeat[1].it = $item[glistening fish meat];
	fishmeat[2].it = $item[slick fish meat];
	comparison_shop [int] veggie;
	veggie[0].it = $item[sea avocado];
	veggie[1].it = $item[sea carrot];
	veggie[2].it = $item[sea cucumber];
	veggie[3].it = $item[sea radish];
	foreach i in fishmeat
		fishmeat[i].price = mall_price(fishmeat[i].it);
	sort fishmeat by fishmeat[index].price;
	foreach i in veggie
		veggie[i].price = mall_price(veggie[i].it);
	sort veggie by veggie[index].price;
	string [item, item] maki;
		maki[ $item[beefy fish meat], $item[sea cucumber] ]  = "giant dragon roll";
		maki[ $item[beefy fish meat], $item[sea carrot] ]  = "musclebound rabbit roll";
		maki[ $item[beefy fish meat], $item[sea avocado] ]  = "python roll";
		maki[ $item[beefy fish meat], $item[sea radish] ]  = "Jack LaLanne roll";
		maki[ $item[glistening fish meat], $item[sea cucumber] ] = "wise dragon roll ";
		maki[ $item[glistening fish meat], $item[sea carrot] ]  = "white rabbit roll ";
		maki[ $item[glistening fish meat], $item[sea avocado] ] = "ancient serpent roll";
		maki[ $item[glistening fish meat], $item[sea radish] ]  = "wizened master roll";
		maki[ $item[slick fish meat], $item[sea cucumber] ] = "tricky dragon roll";
		maki[ $item[slick fish meat], $item[sea carrot] ] = "sneaky rabbit roll";
		maki[ $item[slick fish meat], $item[sea avocado] ] = "slippery snake roll";
		maki[ $item[slick fish meat], $item[sea radish] ] = "eleven oceans roll";
	string sushi = maki[fishmeat[0].it, veggie[0].it];
	int x = floor((fullness_limit() - my_fullness()/3);
	buy(x, $item[white rice]);
	buy(x, veggie[0].it);
	buy(x, fishmeat[0].it);
	buy(x, $item[seaweed]);
	for i from 1 upto x
		cli_execute("create 1 "+ sushi);
}
 
Last edited:

Bale

Minion
Once you got switch statements you really ran off with them, haha. Maps can really be quite elegant if you use them well.

Quite true. You took me in hand there. Though I think you underestimate the power of a simple cli_execute("cheapest infused sake; buy 1 it; drink 1 it;");
 

Rinn

Developer
My ash scripting is pretty paranoid. You should see my quest scripts, they're written as if mafia is out to screw me at every turn. I don't really like combining ash and cli if I don't have to either, but there's a lot of situations where it's unavoidable.
 
Last edited:
Top