Creating a specialized container

Is it possible to create a container that holds only items of a certain kind, or do I have to program such behavior myself?
It is something I would assume is needed all the time, since certain things just don’t fit into others sometimes, but I can find no reference to it. Egg containers that can hold only eggs, pockets that can’t fit a book, that sort of thing.

Sure.

The book/pocket example (large things can’t fit into small containers) I end up doing in practically every game I write, something like this:

[code]A thing can be large.

Instead of inserting a large thing into a container, say “It’s too big.”[/code]

Which can be varied easily to make things have a wider range of sizes, to also account for the size of the container, etc.

As for the egg/carton example (only a certain thing can fit a certain container), you want a relation:

[code]The kitchen is a room.

Fitting relates various things to one container.

The verb to fit (he fits, they fit, he fit, it is fit by, he is fitting) implies the fitting relation.

Instead of inserting something into something while the noun does not fit the second noun, say “[The noun] doesn’t fit in [the second noun].”

The egg is in the kitchen.

The carton is a closed, openable container in the kitchen.

The egg fits the carton.

The watermelon is in the kitchen.

Test me with “open carton/put watermelon in carton/put egg in carton”.[/code]

Awesome! Thanks for the answer. This is great. :slight_smile:

Although, now nothing fits into any container any more, unless I specifically say so. That’s a bit harsh, too, requiring a lot of additional definition and forethought. I’d really prefer a way where I can limit certain containers to a specific thing, and I haven’t worked that out yet.

Not to worry. Just define a new kind of container:

[code]The kitchen is a room.

A specialized container is a kind of container.

Fitting relates various things to one specialized container.

The verb to fit (he fits, they fit, he fit, it is fit by, he is fitting) implies the fitting relation.

Instead of inserting something into a specialized container while the noun does not fit the second noun, say “[The noun] doesn’t fit in [the second noun].”

The egg is in the kitchen.

The carton is a closed, openable specialized container in the kitchen.

The egg fits the carton.

The watermelon is in the kitchen.

The fridge is a closed, openable container in the kitchen. It is fixed in place.

Test me with “open carton/put watermelon in carton/put egg in carton/open fridge/put watermelon in fridge/put carton in fridge”.[/code]

Voila, now only eggs fit in egg cartons, but anything fits in the fridge.

Yes, I see that working. My problem now is that the item I want to put in the container are of a “kind” and not actual items, and Inform tells me I’m not allowed to do that. My case in particular is referring ti a pack of cigarettes, like this.

The player carries some Marlboros. The Marlboros are a specialized container. The indefinite article of the Marlboros is "a[if the Marlboros contain nothing]n empty[end if] pack of". A cigarette is a kind of thing. In the Marlboros are six cigarettes.

If I add the instruction “A cigarette fits the Marlboros.” I am getting an error message. Do you have any idea how I could circumvent this? I used “cigarette is a kind of thing” because I wanted to have six individual ones in the pack and that seemed to be the only way to do it.

“All cigarettes fit the Marlboros” works.

This is all more complicated than I’d bother with, though. I’d drop the “specialized container” business and just write rules:

Instead of inserting something into the Marlboros when the noun is not a cigarette:
	say "That's for your coffin nails, pal. [The noun] won't go."

Yeah, you’re right. I may have been overthinking this, though I had honestly hoped there would be some language construct that would allow me to do something like this

The Marlboros are a container that holds a cigarette.

and be done with it. Sadly, it’s not quite that easy, so your approach might be best, to simply isolate the case.