Liquids: Reporting filling

I’m having a problem understanding how to implement check/carry out/report rules when the circumstances before and after the action change. In this case, I want to say whether liquid flowed from one vessel to another, but I can’t be sure of that unless I know the state of the game world before the carry out rules took place. What’s the proper Informish way to do that? I thought using “if the noun was full” would be the way, but apparently I can’t use “was” with the variable “the noun.” This does not compile:

[code]
A vessel is a kind of thing. A vessel can be full or empty.

Pouring it into is an action applying to two things. Understand “pour [something] into [something]” as pouring it into.

The kitchen is a room.

The teacup is a vessel in the kitchen.
The kettle is a full vessel in the kitchen.

Check pouring something that is not a vessel into something:
say “You can’t pour anything from [the noun].” instead.

Check pouring something into something that is not a vessel:
say “You can’t pour anything into [the second noun].” instead.

Carry out pouring something into something:
if the noun is full, now the second noun is full;
now the noun is empty.

Report pouring something into something:
say “You tip [the noun] over [the second noun][if the noun was full], and water pours into it[otherwise], but nothing comes out[end if].”

Test me with “pour kettle into teacup”[/code]

So what’s the right way?

I think it sad that variables can’t be used with the simple past tense like that. ::whine:: The next-most-elegant way to handle that would likely just be a truth state variable that’s local to the action. The pouring it into action has a truth state called the former state. or somesuch.

I can’t seem to get that working:

The pouring action has a truth state called the source was filled.

Report pouring something into something: say "You tip [the noun] over [the second noun][if the source was filled is true], and water pours into it[otherwise], but nothing comes out[end if]."

[spoiler][code]
A vessel is a kind of thing. A vessel can be full or empty.

Pouring it into is an action applying to two things. Understand “pour [something] into [something]” as pouring it into.

The pouring action has a truth state called the source was filled.

The kitchen is a room.

The teacup is a vessel in the kitchen.
The kettle is a full vessel in the kitchen.

Setting action variables for pouring something into something:
now the source was filled is whether or not the noun is full.

Check pouring something that is not a vessel into something:
say “You can’t pour anything from [the noun].” instead.

Check pouring something into something that is not a vessel:
say “You can’t pour anything into [the second noun].” instead.

Carry out pouring something into something:
if the noun is full, now the second noun is full;
now the noun is empty.

Report pouring something into something:
say “You tip [the noun] over [the second noun][if the source was filled is true], and water pours into it[otherwise], but nothing comes out[end if].”

Test me with “pour kettle into teacup”[/code][/spoiler]

That gives me this run-time error:

A workaround might be using a three-valued property:

A vessel is a kind of thing. A vessel can be full, emptied or empty.

...
   
Carry out pouring something into something:
   if the noun is full, now the second noun is full;
   now the noun is emptied.
   
Report pouring something into something:
   say "You tip [the noun] over [the second noun][if the noun is emptied], and water pours into it[otherwise], but nothing comes out[end if]."; now the noun is empty.

Ugh! If I’m going to put side effects into a report rule, I might as well just print a message during a carry out rule. Or just do everything with an Instead rule.

Yeah, the elegant way is definitely not to have results happen in the report rule.

Using action variables is the “right way” to handle this problem, if there is one; indeed, part of the point of action variables is precisely to store this kind of information for elegant reporting.

The fact that Inform is even trying to read this as a reference to the kettle’s properties is because you’ve defined “source was filled” as a variable of the “pouring action”; but you need to refer to the “pouring it into action” instead. Without that, it doesn’t know of a “source was filled” variable because it’s affiliating that variable with a totally different (possibly even nonexistent) action rulebook; so it has no context to understand it within this rulebook, and it tries to see if maybe it’s a property of the most recent object we were talking about, instead. And when that doesn’t work, it throws a runtime error.

I see. I always have problems with two-noun actions - when to call it “pouring it into” and when to call it “pouring something into something.” I’ve had the impression in the past that simply “pouring” will match in some circumstances, but maybe I was mistaken.

It will match in Instead rules etc., I think, if there’s no other competing action name; but for specifying the full action name (as here) you need the “it” and the preposition.

:blush:

:blush:

Quite so! I should have made that an “Every turn when a vessel (called the utensil) is emptied: now the utensil is empty.” kind of thing.

:blush:

Well, happily no work-around needed anyway.

My approach is just to consider the empty case as a failure, and catch it with a check rule. For more complex cases, I tend to wind up with actions invoking other actions.

Maybe that’s not sufficiently general – ie, you might want to store and report the substance being poured. An action-local variable certainly works.