How do I create a container that is also a supporter?

I need an object (night table) to have both something on it and also in it. How do I create such thing?

Basically, make the object a supporter, and make the container part of the supporter. I use this:

A drawer is a kind of container. It is openable and lockable. A drawer is usually closed.

A desk is a kind of supporter. A drawer is a part of every desk.

Instead of opening a desk (called D):
	if a drawer (called Dr) is part of D:
		try opening Dr;
		
Instead of closing a desk (called D):
	if a drawer (called Dr) is part of D:
		try closing Dr;
5 Likes

If you’re using 6M62, you can do something like this.

A multipurpose is a kind of container. Include (- class K6_supporter -) when defining a multipurpose. Include (- has transparent supporter -) when defining a multipurpose.

Annoyingly, that little trick no longer works in Inform 10.

Hope this helps.

I wouldn’t recommend that, because it means there’s no distinction between things on the desk and things in the desk.

2 Likes

True, but it does give that exact answer to the original question. If the container is meant to be a separate from the supporter then I’d highly suggest @rileypb 's solution over this one.

Here’s a quick implementation of a trunk that can contain things with a lid that can support things.

"Untitled"

Laboratory is a room. The Circus is south of Laboratory.

A circus trunk is an openable, closed container in Laboratory. "A well-used circus trunk is here. Colorful painted images of scary clowns have faded with wear[if trunk lid supports something]. On top of the trunk is [a list of things supported by trunk lid][end if]." The description is "It's a circus trunk that can contain things[if trunk lid supports something], but at the moment it's furniture displaying [a list of things supported by trunk lid][end if] on top of the lid."

Circus trunk is pushable between rooms. Circus trunk is fixed in place. Instead of taking circus trunk: say "It's too heavy to carry, but you may be able to push it in a direction like PUSH TRUNK SOUTH."

The trunk lid is a supporter. It is part of circus trunk. Understand "top of the/-- trunk" as trunk lid. The description is "[if circus trunk is open]The trunk lid is open so you can put things inside.[otherwise]The trunk lid is closed to serve as furniture.[end if]"

A bowling trophy is on trunk lid. 
A bowling ball is on trunk lid.
A magic feather is in circus trunk.

Rule for deciding whether all includes the circus trunk: it does not.

Instead of opening trunk lid:
	try opening circus trunk.

Instead of closing trunk lid:
	try closing circus trunk.

After opening circus trunk:
	if trunk lid supports something:
		say "Everything that was on top of the circus trunk ([the list of things supported by trunk lid]) is now on the floor.";
		now everything supported by trunk lid is in the location;

Before putting something on trunk lid when circus trunk is open:
	try closing trunk lid;

Check putting something on trunk lid when circus trunk is open:
	say "You can't put stuff on the circus trunk while it is open." instead.

Check putting something on circus trunk:
	try putting the noun on the trunk lid instead.

Test me with "x trunk/x lid/open trunk/take all/take trunk/push trunk south/put all on trunk"

Yeah, but that looks like the u-stor-it example, whereas I want just a container that can be a supporter without any lid/drawer opening mechanics.

@Draconis That’s okay for my use case.

Okay, solved it:

A table is a kind of a supporter. The specification of a table is "A supporter joined with a container."
A table-inside is a kind of a container. A table-inside is part of every table. The specification of the table-inside is "A container part of the table."
Before putting something on a table when a table-inside (called the item) is part of the second noun:
	try inserting the noun into the item instead.
Before inserting something into a table-inside which is part of a table (called the item):
	 try putting the noun on the item instead.
Instead of examining the table (called t) when something is in table-inside (called ti):
	say "It is [The noun]. On it there [is-are a list of things on the t] and inside there [is-are a list of things in the ti]."
After printing the name of a table (called the item) while listing contents of a room:
	if a table-inside (called the second item) which contains something is part of the item:
		say " that has [a list of things in the second item] in it".
		

and then actual table definition:

Night table is a table in the bedroom.
A pen is on Night table.
Chocolate bar is edible thing in the Night table's table-inside. The description of the chocolate bar is "A lovely sweet treat". After eating chocolate bar, say "Mmm... so sweet..."

Bit of cargo cult programming in there, but it works so I’m okay with that.

1 Like