Associating two things as... siblings?

I am writing a story where the player goes occasionally berserk and as a consequence, destroys every thing she examines. After the destruction, the thing goes “nowhere” and I want another thing to come from “nowhere,” which is what is left of the original thing.

For example, a “crystal glass” gets smashed, goes nowhere and “shards of glass” come from nowhere.

I want to create a general rule that connects each thing with a sibling thing (eg the crystal glass with the shards of glass), but I don’t know how. We can say for instance:

Every thing has a number called whatever.

or:

Every thing has a text called so-and-so.

but we can’t say:

Every thing has a thing called sibling.

can we?

How can I associate two things in such a way?

Thanks!

Yes, you can do this. (I believe the default value of sibling will be the “yourself” object, unless you tell Inform otherwise.)

A thing can be breakable, unbreakable or broken. 
A person is usually unbreakable.

Every thing has a thing called the ruin.

Instead of examining a breakable thing:
     say "You smash [the noun] furiously!";
     now the ruin of the noun is in the holder of the noun;
     now the noun is off-stage.

Instead of examining a broken thing:
     say "You regard [the noun] with satisfaction." 

The player holds a mirror. The shards of glass are a broken thing. The ruin of the mirror is the shards of glass.

Actually, you can say “Every thing has a thing called the sibling.” However, a slightly better way to handle this might be relations. With relations, you can say something like:

Siblinghood relates one thing (called the sibling) to one thing. The verb to be linked to means the siblinghood relation.

You can then write code like “The shards of glass are linked to the mirror,” and refer to things like “the sibling of the noun”.

Below is a working example. Since you specifically talk about smashing stuff in your OP, I used terminology to reflect that.

[code]Test Chamber is a room.

Breakage relates one thing (called the broken version) to one thing.

The verb to be the remains of means the breakage relation.

A radio is in the test chamber.
A paperback book is in the test chamber.
A mirror is in the test chamber.

Some smashed bits of plastic are the remains of the radio.
Some ripped up pages are the remains of the paperback book.
Some shards of glass are the remains of the mirror.

Instead of attacking something:
if the broken version of the noun is nothing:
say “You’ve done all the damage you can to [the noun].”;
otherwise:
say “You violently reduce [the noun] into [broken version of the noun].”;
remove the noun from play;
move the broken version of the noun to the location.

Test me with “break radio / break book / break mirror / break glass”.[/code]

I was going to suggest relations as well, but one other thing you could do is make the “pieces” of a thing part of a thing.

[rant=hulk smash][code]China Shop is a room.

The block attacking rule is not listed in any rulebook.

Check attacking:
if the noun is not smashable:
say “You bat [the noun] around a bit but it frustratingly does not break in any satisfying way.” instead.

Check examining remains:
if the noun is part of something (called parent):
say “That may be a future state of [the parent] if you’re not careful.” instead.

Carry out attacking a smashable thing (this is the component parts rule):
if the noun incorporates remains (called bits):
now bits is in the location;
remove the noun from play.

Report attacking a smashable thing:
say “You smash [the noun] into bits, satisfyingly.”

A thing can be smashable.

Last report examining a smashable thing:
say “(You note it looks rather fragile and should be handled with care.)”

Remains is a kind of thing.

A glass tray of crystal goblets is in China shop. It is smashable.
Some glass shards are remains. It is part of glass tray of crystal goblets.

A jenga tower is in China shop. It is smashable.
Some rectangular wooden blocks are remains. It is part of jenga tower.

A heavy glass ashtray is in china shop.

[/code]

[/rant]

True. If you don’t want the player to refer to the pieces before the thing is broken, you can add:

Rule for deciding the concealed possessions of a smashable thing: if the particular possession is remains, yes.

Wow! That’s a lot more than I could have asked for! Thanks for all the food for thought, friends!

So, to get it straight, when something is part of a parent thing, is the player aware of the parent only and not of the part? In order to get the part to appear it has to stop being a part? Else one has to explicitly state its presence in the description?

Thanks so much, everyone!
G.

Parts are always visible to the player, unless you provide a “for concealing possessions of” rule that specifically hides them; see my post above for an example of how to write such a rule.

(Forgive me if you know this, but can be confusing.) Above, Mike says “visible to the player” in the Inform sense - in scope for the player. Otherwise, component parts of a parent won’t explicitly be mentioned unless the parser asks a question like “Do you mean the wine glass or the glass shards?” It won’t refer to them under normal circumstances such as describing a room - if you want the player to interact with component parts and “be aware” of them, it’s a good idea to mention them in the prose description or somewhere else appropriate.

If a crank is part of a machine, Inform will say “You can see a machine here.” It’s up to the author to describe the machine as having a crank as a part.

Yes, this is what I meant. Indeed it gets confusing at the beginning. Thanks for clarifying that!

Hello,

I am stumbling over something that I don’t know how to fix.

In the following extract, when the player types “smash glass,” everything works as desired:

[code]“Glass Test” by Giannis

A remainder is a kind of thing.

A glass is a kind of container.

The pile of broken glassware is a kind of remainder. The plural of pile of broken glassware is piles of broken glassware.

Every glass incorporates a pile of broken glassware.

Rule for deciding the concealed possessions of a thing (called the parent):
if the parent is not a container, no;
else:
if the particular possession is remainder, yes;
else no.

Instead of attacking anything:
smash the noun blindly.

To smash (T - a thing) blindly:
say “Blinded by your rage, you completely and utterly destroy [the T].”;
if the T incorporates a remainder (called bits):
say “Now only [a bits] [are] left at your feet.”;
now bits is in the location;
now the T is nowhere.

The Kitchen is a room.

Three glasses are in the kitchen.[/code]
However, if I add a specific glass (eg. a beer glass) in the room, when I smash it, I get:

. It actually adds the parent’s name while printing the “bits” name.

How do I fix this?

Thanks in advance!

Inform will always create these compound names when you create objects with parts; see 4.16 of Writing With Inform. As far as I know, there’s no way to stop it happening. Of course, you could change the printed name easily.

But do you really need to use incorporation here? If the piles of broken glass are supposed to be indistinguishable, then just make a sufficient number, keep them off-stage until a glass gets smashed, and then switch one in.

Edit: I guess if you want to stick with the incorporation method, you could make a stack, and then incorportate them at start of play. This will prevent Inform auto-naming them.

There are four piles of broken glassware.

When play begins:
     repeat with X running through glasses:
           now X incorporates a random off-stage pile of broken glassware.

If you define a custom relation instead of using incorporation, you can even use it to create a broken pile of glassware for each glass:

[code]“Glass Test” by Giannis

A remainder is a kind of thing.

A glass is a kind of container.

The pile of broken glassware is a kind of remainder. The plural of pile of broken glassware is piles of broken glassware.

Shattering into relates one thing to one thing. The verb to shatter into means the shattering into relation.

Every glass shatters into a pile of broken glassware.

Instead of attacking anything:
smash the noun blindly.

To smash (T - a thing) blindly:
say “Blinded by your rage, you completely and utterly destroy [the T].”;
if the T shatters into a remainder (called bits):
say “Now only [a bits] [are] left at your feet.”;
now bits is in the location;
now the T is nowhere.

The Kitchen is a room.

Three glasses are in the kitchen.[/code]

Then you don’t have to worry about any complications that might result from having the broken pile contained in the glass (for instance, you don’t need the concealed possessions rule).

The slightly thing obscure thing that makes this work is that, when you create an assembly like this (that is, create new objects with a relation like “Every glass incorporates a pile of broken glassware” or “Every glass shatters into a pile of broken glassware”), it makes the possessive part of the name if the assembly is part of the object, but not for other relations. So if you have “Every person incorporates a nose” then the nose that is part of Jane will become “Jane’s nose,” but if you write “Every person carries an ID” the ID that Jane carries will just be “ID.” Sections §4.15-16 of the documentation explain some of the stuff about these assemblies and names, but I’m not sure they explain this particular thing.

Thanks a lot, guys!

Deja vu! I think we had this thread before?

Incorporating broken pieces in the whole was done to avoid using relations.

[Merging threads, since this all kind of goes together]

Yes indeed, I first chose incorporating, but then I found out the compound name issue!

The pile of broken glassware is a kind of remainder. The printed name of a pile of broken glassware is usually "pile of broken glasware". The printed plural name of a pile of broken glassware is usually "piles of broken glassware".

Or yes, or use “carries” (he said reading upward cluelessly) :wink: