Putting an object on one of many similiar supporters in a room

In my game is a café, which contains some tables and chairs.

If player places item on table I want the game to say “You place the item on one of the tables”

In the room description I want it to say "You can see some tables (on one of which is …list items on tables).

1 Like

I gave an attempt at coding something for this. Your mileage may vary :slightly_smiling_face:

The scene is a Cafe’ with five tables and several items that can be placed on the tables. Putting anything on a table randomly selects a table and places the object. Looking describes the tables in the room and what is on them. Here is the code:

The plural of table is tables. A table is a kind of supporter.

Cafe' is a room.  There are 5 tables in the Cafe'. There is a reservation marker in the Cafe'.  There is a vase of flowers in the Cafe'.  There is a place mat in the Cafe'.  There is a menu in the Cafe'.

Instead of putting anything on a table:
	let P be a random table;
	Now the noun is on P;
	say "You select a table and place the [noun] on it.[line break]";
	try looking;
	stop the action.

Here is how the game play looks when placing objects on tables.

Cafe'
You can see five tables, a reservation marker, a vase of flowers, a place mat and a menu here.

>take all
reservation marker: Taken.
vase of flowers: Taken.
place mat: Taken.
menu: Taken.

>put flowers on table
You select a table and place the vase of flowers on it.

Cafe'
You can see a table (on which is a vase of flowers) and four tables here.

>put mat on table
You select a table and place the place mat on it.

Cafe'
You can see a table (on which is a vase of flowers), a table (on which is a place mat) and three tables here.

>put menu on table
You select a table and place the menu on it.

Cafe'
You can see a table (on which is a vase of flowers), a table (on which is a place mat), two tables and a table (on which is a menu) here.

>put marker on table
You select a table and place the reservation marker on it.

Cafe'
You can see a table (on which are a reservation marker and a vase of flowers), a table (on which is a place mat), two tables and a table (on which is a menu) here.

>take all 
reservation marker: Taken.
vase of flowers: Taken.
place mat: Taken.
menu: Taken.

>put all on table
menu: You select a table and place the menu on it.

Cafe'
You can see four tables and a table (on which is a menu) here.

place mat: You select a table and place the place mat on it.

Cafe'
You can see three tables, a table (on which is a place mat) and a table (on which is a menu) here.

vase of flowers: You select a table and place the vase of flowers on it.

Cafe'
You can see a table (on which is a vase of flowers), a table (on which is a place mat), two tables and a table (on which is a menu) here.

reservation marker: You select a table and place the reservation marker on it.

Cafe'
You can see a table (on which is a vase of flowers), a table (on which is a place mat), a table (on which is a reservation marker), a table (on which is a menu) and a table here.

Here is a different question that came up regarding examining duplicate containers.

2 Likes

Thanks, this is super helpful!

Is there any reason that the tables have to be separate objects? Because from your description it sounds like you might just want to treat them as a single supporter. Then all you need to is find a hook for writing “on one of which is”:

Cafe is a room. Some tables are a supporter in the cafe. Understand "table" as the tables.

For writing a paragraph about the tables when something is on the tables: 
	say "You see [a tables] (on one of which [regarding the number of things on the tables][are] [a list of things on the tables])."

(This rather pedantically makes “is” agree with the number of things on the table, but honestly leaving it as “is” is probably more natural, so you can omit that part.)

You could similarly adjust the “examine supporters” rule to put your phrase in. Or you can go through the rule responses, see which contain the word “on” (you can do this by typing “responses all” in a new project and searching for the full word “on”), and adjust them all:

Cafe is a room. Some tables are a supporter in the cafe. Understand "table" as the tables.

The you-can-also-see rule response (B) is "On [if the domain is the tables]one of [end if][the domain] [we] ".
The examine supporters rule response (A) is "On [if the noun is the tables]one of [end if][the noun] ".
The standard search supporters rule response (A) is  "On [if the noun is the tables]one of [end if][the noun] ".
The list writer internal rule response (R) is "on [if the noun is the tables]one of [end if][if the noun is a person]whom[otherwise]which[end if] ".
 The list writer internal rule response (S) is ", on top of [if the noun is the tables]one of [end if][if the noun is a person]whom[otherwise]which[end if] ".

The player carries a rock and a roll.

…OK, due to tedium I fear I probably skipped a couple, particularly the scenery supporters ones since I didn’t define the tables as scenery. But if you get them all this will be a particularly comprehensive replacement. You still do get that pedantic are/is thing I mentioned, which may or may not be an advantage.

(Spoilered for sheer irrelevance: with any luck the additional responses that need editing will include an (A) and a (B), so the entire list of edited responses can spell out a tribute to the Dutch saxophonist Ab Baars.)

4 Likes

Thanks, this is exactly what I wanted.

I found this post very informative. Wish we could give mutiple likes! :heart: :heart:

2 Likes

Matt’s solution is the better one, but for the sake of completeness, Inform has a neat feature with indistinguishable objects:

A table is a kind of supporter. There are five tables in the Café.

If you then say “PUT APPLE ON TABLE” or whatever, Inform will understand that the tables are currently indistinguishable, and pick one arbitrarily.

4 Likes

So in my example picking a random table is essentially redundant given the implicit behavior of Inform?

Yep! Though Inform’s default handling of this isn’t perfect, and sometimes miscalculates when things are truly “identical”. So test it thoroughly before relying on it.

1 Like

It is super cool to know that is a built in feature! Thanks so much for the info :grin: