Newbie here, question about the combo of "inserting"/"putting" + "if"+"say"

Hi guys! I’m creating a surreal cooking type of game on inform 7, but I ran into some issues in the cooking description process. After placing the butterfly in the pan, the code runs fine, completing the “say” part, but when I try using the same code for the other ingredients , the “say” part wouldn’t run, the result would be like this:

put butterfly in pan

You put the butterfly into the pan.
The butterfly dissolves into iridescent liquid on contact, coating the pan in a shimmering film.

put egg in pan
(first taking the egg)

pour liquid in pan
(first taking the red liquid)

I tried deleting the butterfly codes , leaving only the egg and liquid code, and the result becomes:

put egg in pan

(first taking the egg)
You cracked the egg into pan,
The egg white spreads across the blue-coated pan like slime, its edges crisping into fractal patterns.
The yolk glows golden, basking you in its luscious glory.

and I tried deleting the egg code as well, and the liquid code
runs fine, able to “say” .

Is there a way I can fix this, to let all ingredients list out its description after putting it in the pan? Thanks a lot for reading this.

Here is the code:

Understand "put [things] in [something]" as inserting it into. Understand "put [things] on [something]" as putting it on.

After inserting something into something:
	if the noun is butterfly:
		if the second noun is pan:
			now the butterfly is nowhere;
			now the description of the pan is "The pan is now glazed with an unnatural blue film. [if something is in the pan]It contains [a list of things in the pan].[end if]";
			say “You put the [noun] into the [second noun].[line break]The butterfly dissolves into iridescent liquid on contact, coating the pan in a shimmering film.”
			
After inserting something into something:
	if the noun is egg:
		if the second noun is pan:
			say “You cracked the [noun] into [second noun], [line break]The egg white spreads across the blue-coated pan like slime, its edges crisping into fractal patterns.[line break]The yolk glows gloden, basking you in its luscious glory. ”;
			continue the action.
			
Understand "pour [things] in [something]" as inserting it into.
			
After inserting something into something:
	if the noun is liquid:
		if the second noun is pan:
			say “You pour the [noun] into [second noun], [line break]The red liquid seeps within the egg mixture, rather bloody looking.[line break][if the player carries the spatula]You stir the mixture well. After a minute, the egg mixture starts to puff up. ”;
			continue the action.
``

The key is that “after” rules stop the action by default. So the first “after” rule runs, it sees that the noun is not the butterfly, so it stops the action without printing anything.

You’ll want to put your "continue the action"s outside the “if” statements:

After inserting something into something:
	if the noun is butterfly:
		if the second noun is pan:
			now the butterfly is nowhere;
			now the description of the pan is "The pan is now glazed with an unnatural blue film. [if something is in the pan]It contains [a list of things in the pan].[end if]";
			say “You put the [noun] into the [second noun].[line break]The butterfly dissolves into iridescent liquid on contact, coating the pan in a shimmering film.”;
	continue the action.

Thank you so much!!! I’ve been trying and searching for ages and never thought it’s because of the placement of “continue the action”. Bless you and your spectacular brain!

Only one thing, after placing “continue the action” outside the “if” statements, the result will now add an extra sentence at the end, which doesn’t really match the order of things.
the result reads :

put butterfly in pan

You put the butterfly into the pan.
The butterfly dissolves into iridescent liquid on contact, coating the pan in a shimmering film.
You put the butterfly into the pan.

put egg in pan

You cracked the egg into pan,
The egg white spreads across the blue-coated pan like slime, its edges crisping into fractal patterns.
The yolk glows golden, basking you in its luscious glory.
You put the egg into the pan.

pour liquid in pan

You pour the red liquid into pan,
The red liquid seeps within the egg mixture, rather bloody looking.
You stir the mixture well. After a minute, the egg mixture starts to puff up.
You put the red liquid into the pan.

I tried to eliminate the default text by using the “silently try”, then inform 7 spammed me with a run time error…

I can’t eliminate the default response entirely , as I need it at other places, is there a fix for this? Thanks a lot!

The reason is that “continue the action” outside of any conditions in the after rule will continue the action every time the rule is run, unless something ends the action.

You can try turning the after rule into a report rule:

Report inserting butterfly into something:
	if the second noun is pan:
		now the butterfly is nowhere;
		now the description of the pan is "The pan is now glazed with an unnatural blue film. [if something is in the pan]It contains [a list of things in the pan].[end if]";
		say “You put the [noun] into the [second noun].[line break]The butterfly dissolves into iridescent liquid on contact, coating the pan in a shimmering film.”;
		rule succeeds.

The more specific rule should be triggered before the standard report rule. Here, “rule succeeds” tells inform not to bother with any other report rules.

Or, you can use an else:

After inserting something into something:
	if the noun is butterfly:
		if the second noun is pan:
			now the butterfly is nowhere;
			now the description of the pan is "The pan is now glazed with an unnatural blue film. [if something is in the pan]It contains [a list of things in the pan].[end if]";
			say “You put the [noun] into the [second noun].[line break]The butterfly dissolves into iridescent liquid on contact, coating the pan in a shimmering film.”;
		otherwise:
			[Corrected for bug found by Draconis]
			continue the action;
	otherwise:
		continue the action.

Here, the otherwise makes sure inserting anything other than the butterfly continues on to the report rules. The rule’s normal behavior of stopping the action will stop the action when the butterfly is inserted.

1 Like

Though with that last example, it will now print nothing if you put the butterfly into something that’s not the pan.

1 Like

Because action processing is so central to using Inform but so many details are not covered in early chapters of Writing with Inform (the first half of the built-in documentation), it’s probably worth reading certain parts of the documentation out of order.

I’d strongly recommend spending some time with section 12.2 How actions are processed (which includes a very helpful reference diagram) and the whole of chapter 19 Rulebooks. Not only will it make some details of the suggested solutions clearer, it will keep you from running into the same types of problems again and again as you work on new parts of your scenario.

1 Like