Inform 7: Multiple instances of a kind of thing where some (but not all) change properties

0 votes
79 views
asked Jul 21 in Authoring by Phil C
edited Jul 24 by Alex

Just to play around beginning to learn Inform 7, I created a room, the Kitchen, in which there are various dishes, bowls, glasses, utensils, etc. lying around. The object of the "game" is to wash them all and put them away (in various cabinets and drawers) where they belong.

My question relates to (for example), a fork being clean or dirty. I included an action "wash [something]" which changes this property to "clean." (The game prevents the user from putting away dirty dishes until they have been washed.)

The problem arises when I say "On the counter are 2 forks, 3 spoons, and 7 knives." What is the best way to construct these objects so that the game will keep track of which ones are clean, and which ones the player is interacting with (examining, taking, washing, putting away, etc.) at any given time? Is there a particular chapter or example in the documentation that I should refer to for a case like this?

I found the example in the Inform manual where the player has to sort peas and lentils (Example 87 "Sand"), but in that case, every pea and every lentil was identical to all the others, and the only thing that mattered was their quantity and which container they were placed in... it wasn't a matter of changing the properties of any individual pea or lentil.

1 Answer

0 votes
answered Jul 21 by bg (692 points)
edited Jul 21 by bg

You could do something like this to keep track of whether a utensil is clean or dirty. I'm not sure exactly what you are going for when you say you want to keep track of which ones the player is interacting with, though.

This is based on the "Early Childhood" examples in the manual.

Cleanliness is a kind of value. The cleanlinesses are clean and dirty.

A kitchen-implement is a kind of thing.
A spoon is a kind of kitchen-implement.
A knife is a kind of kitchen-implement.
A fork is a kind of kitchen-implement.

A kitchen-implement has a cleanliness. The cleanliness of a kitchen-implement is usually dirty.

Before printing the name of a kitchen-implement, say "[cleanliness] ".
Before printing the plural name of a kitchen-implement, say "[cleanliness] ".
Understand the cleanliness property as describing a kitchen-implement.

Washing is an action applying to one thing.
Understand "wash [thing]" as washing.

Check washing:
    if the noun is not a kitchen-implement:
        say "There's no need to wash [the noun]." instead;
    otherwise if the noun is clean:
        say "You've already washed [the noun]." instead.

Carry out washing:
    say "You wash [the noun].";
    now the noun is clean.

Kitchen is a room.

A counter is a supporter in the Kitchen.
On the counter are 2 forks, 3 spoons, and 7 knives.
commented Jul 21 by PhilC (1 point)
That worked. What I was missing was "Understand the cleanliness property as describing a kitchen-implement." Without that, at least from what I gather, there was no way to distinguish the various forks/spoons etc from one another, especially once some were washed and others weren't. THANK YOU!
commented Aug 22 by eduardomezencio (36 points)
I have just copied and pasted this code, and then I tried to play the 'game'. When I enter "clean dirty fork" it executes the action, but after that both forks are still dirty...
commented Aug 22 by bg (692 points)
edited Aug 22 by bg
In the example, the only command that will lead to the new "washing" action is "wash."

"Clean" is a built-in command that will lead to the built-in "rubbing" action.

If you want to reassign "clean" to the washing action, you could say

Understand the command "clean" as something new.
Understand "clean [thing]" as washing.

Another way you could handle it is to just make "wash" a synonym for "rub" (Understand "wash [thing]" as rubbing) instead of creating a new washing action, and then write new rules that refer to rubbing instead of washing.
commented Aug 23 by eduardomezencio (36 points)
Oh yes. I'm feeling very stupid now :/
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...