Creating an action

I’m trying to get Inform to recognize the action of pouring.

[code]The milk is a thing. It is inside the bottle.

The description of the milk is “Vitamin A.”

Pouring is an action applying to one visible thing.

Understand “pour” as pouring.

Carry out pouring anything:
say “Okay, man, you got the milk in the bowl.”;
now milk is in bowl;
continue the action.[/code]

But when I tell the parser to “pour milk” it comes back at me with:

I only understood you as far as wanting to pour.

I’m not an expert by any means, but I can see some problems with your code.
First of all, the pouring action you created is missing the noun:

Understand "pour [something]" as pouring.

Without “something” the parser doesn’t even look for an object to pour, that’s why it doesn’t accept your command. The action as written works simply by typing POUR.

If milk is the only thing you need to pour in your story, you might leave it as is, without an object:

Pouring is an action applying to nothing. [If there's no need to specify anything since you can only pour milk, it works anyways]

Understand "pour" or "pour milk" as pouring. [Probably the player would try POUR MILK, even if the obkect isn't needed, and this should fix it]

Carry out pouring: [there's no object again]
	say "Okay, man, you got the milk in the bowl.";
	now milk is in bowl;
	continue the action.

If you need to pour something other than milk, you should tweak the code some more.

OK, man, I got the milk in the bowl with the [something] addition. Thanks.

If you’re going to limit the grammar to milk only then you should use “pour [milk]” – otherwise the parser won’t understand its possible synonyms or >POUR THE MILK, among other problems. (Although it’s usually best not to do that at all because the parser’s error message for trying to pour anything else will then be rather cryptic.)

Further problem: Although “actions” reports that the act of pouring succeeds, “look” reveals there’s no milk or cereal in the bowl. The second and third lines of each “Carry out” rule never run.

[code]Pouring is an action applying to nothing.

Understand “pour” or “pour milk” or “pour cereal” as pouring.

Carry out pouring:
if noun is milk:
say “Okay, man, you got the milk in the bowl.”;
now milk is in bowl;
continue the action.

Carry out pouring:
if noun is cereal:
say “Okay, man, you got the Wheaties in the bowl. What a champion you are!”;
now cereal is in bowl;
continue the action.[/code]

Right now you’ve got the action defined as applying to nothing, so there is no noun, and the “if noun is…” clauses are always false. Go back to having the action apply to one thing with “pour [something]” in the Understand line.


Out of curiosity, and forgive me for going slightly off-topic but maybe holmes_iv will benefit from this little side-track, what about “pour container” instead of “pour liquid”? As in, pour the flask (in which the milk is) rather than pouring the milk? Is that not acceptable English? (Serious question; I was never sure on this point). I wouldn’t like, as a player, to guess the syntax the game wants me to use if I’ve got the right idea and I’m writing proper English.

(it’s a bit like “tie rope”. I never really know if I have to type “tie rope to hook” or simply “tie hook”, or whether “tie hook to rope” - less correct but understandable, I think - will parse as I want it to or give me a misleading error message)

Yeah, it’s best to implement as many variations as possible, even if all of them aren’t 100% grammatical. Also “pour [something] in/on/to/into [container]” and if you want to get fancy, correctly interpret “pour a glass of [something]”.

Hmmm, “pour a/-- [container] of [something]”? :slight_smile:

That’s a tricky case because “pour a glass of milk” is the same as “pour the milk into the glass” and “pour the carton of milk” would be the same as “pour the milk from the carton.”

My mind immediately leapt at various ways in which to work around the scenarion you’ve described, and I was having quite a lot of fun, when I realised it would utterly and hopelessly derail this thread for the net benefit of a pickyness that just isn’t practical.

But I had fun for about five minutes! I haven’t the time now, but maybe I’ll open up I7 when I come home tonight; I expect to be unable to sleep, so I’ll amuse myself trying to smooth this out.

emily has a liquid handling/fluid containers extension.

Then I shan’t bother. :slight_smile:

For Oppositely Opal, I did:

[code]Pouring it into is an action applying to two things. Understand “pour [something] on/in/onto/into/down [something]” as pouring it into.

Check pouring it into:
instead say “That’s not something you can do.”[/code]

Then I wrote instead rules for the few things that could actually be poured.