What is inferred from a relationship?

Ok, so my title sucks. So what do I mean?

I am creating a “dungeon crawl” system using Inform7. I have created a new “wielding” relationship which sets which weapon the actor is going to use for attacking. This works great, allowing the player to “wield sword” and it does the usual checks and tweaks to take if not carried, ‘unwield’ if dropping, etc.

However when it comes to setting up the other characters, if I say “the skeleton is wielding the sword” then the item does not appear in the showme list, I have to first write “the skeleton carries the sword” otherwise the sword is nowhere.
It is important that the wielded item is carried as when an actor dies there is a corpse dropped with all the items they carried for looting fun.

Sure I could write out the carried and wielded relationship for every character, but surely there is an easier way?!
After all I can say “the skeleton wears boots” and the boots are carried as well as worn. How does the wearing relationship imply the carried by relationship?

If all you need to do is to make sure that you can write “The skeleton wields the sword” in your code and the game will have the skeleton carry the sword as well, you could try something like this:

When play begins: repeat with item running through weapons: if a person (called the bearer) wields the item: now the bearer carries the item.

This will move every weapon into the right person’s inventory at the beginning of the game. (Make sure you aren’t doing any checks before that When Play Begins rule runs that depend on the weapon being in the right place.) If you want to make sure that a weapon can only be wielded when it’s in the inventory, and gets unwielded whenever it’s removed from the inventory, you need to write more rules to make it happen; but it sounds like you’ve already done that.

Here’s my whole test code:

[code]Cavern is a room.
A weapon is a kind of thing.

The skeleton is a person in the cavern.

The sword is a weapon. The mace is a weapon.

Wielding relates one person to one weapon. The verb to wield means the wielding relation.

The skeleton wields the sword. The player wields the mace.

When play begins:
repeat with item running through weapons:
if a person (called the bearer) wields the item:
now the bearer carries the item.[/code]

Thank you Matt, that works great.
I have no idea why I was so stubbornly pursuing fixing this in the relationship when it’s just a shortcut

I actually flipped it around as each character/monster can only wield 1 item and I expect there to be more items than actors:

When play begins: repeat with subject running through people: if the subject wields something (called the item), now the subject carries the item.

Thanks again for the quick reply!

This is actually a very interesting question. How is the special nature of built-in relations like wearing implemented such that specifying something is worn also automatically makes it carried? Does this happen at the I6T level, or even deeper in the guts of the compiler?

More generally: Is that sort of “dual assignment” of relations based on a given verb something that could be replicated for your own relations, as Stephen Blake might do here? Would it be an interesting feature request to be able to specify, for example, “The verb to wield means the wielding relation. The wielding relation implies the carrying relation.” or something similar?

I7 makes worn things carried when it generates I6 code, a rule that appears to be built in to the I7 compiler.

If we compile this program:

Test Chamber is a room.

Bob is a man in Test Chamber.

Bob wears a hat.

I7 produces this I6 code:

Object I125_test_chamber ""

Object -> I126_bob ""

Object -> -> I127_hat ""
    has clothing
    has worn

(… represents code that I’ve elided.)

We can see that the hat is declared to be contained within Bob (-> ->) and that it has the clothing and worn attributes set.

The preceding applies to things that are worn initially. Containment for things that later become worn is handled by the “can’t wear what’s not held” and “standard taking off” rules in the standard rules.

Is that the whole story, though? We can declare “now Bob wears the hat” and that should get the hat to be contained by Bob even though it doesn’t invoke any action rules.

You’re right.

The phrase “now Bob wears the hat” translates to WearObject(I127_hat,I126_bob), where WearObject is defined in the WorldModel.i6t template file as:

[ WearObject X P opt;
	if (X == false) rfalse;
	if (X notin P) MoveObject(X, P, opt);
	give X worn;

Similarly, when a worn object is moved directly, MoveObject clears the worn attribute.

Yes, this is exactly the kind of feature I was thinking would logically exist in the I7 side of things to allow us to define behaviors for relationships.
However digging through the Standard Rules file I found nothing.

I think this would be a useful feature in certain situations. “mother” implies “parent” implies “family”, “glued together” implies “same containment”, etc.

For interested parties, I’ve submitted a uservoice request about this:

inform7.uservoice.com/forums/57 … -imply-oth

Please feel free to add your votes and/or comments.