Understanding a carried bag of stuff as being carried by the player

I have a lot of things in my game that are controlled by “if item is carried by the player…”

I recently allowed the player to put most of their items into a satchel that they carry around with them (it is a closed openable container and it’s wearable), but now if an item is in the bag, the game doesn’t see it as being “carried”.

Is there any way to make Inform understand that the contents of the satchel when it is carried are also carried by the player?

You want to make use of the built-in enclosure relation. See WWI 3.25 The location of something for details. (WWI is “Writing With Inform”, the built-in documentation.)

if the player encloses item...

or

if item is enclosed by the player...

Note that this would also include things in the player’s inventory that are not inside the satchel. You can substitute satchel for player if you want the check to be satchel-specific.

6 Likes

Thank you so much!! That worked great!

1 Like

Note that ‘enclosed by the player’ also includes anything the player is wearing.

If you want to exclude worn things, you could define a new relation to mean either direct or indirect carrying, but excluding wearing, like so:

Bearing relates a person (called the bearer) to a thing (called the load) when the bearer encloses the load and the bearer does not wear the load.
The verb to bear means the bearing relation.

You can now write things like ‘If Mr Darcy bears the pistol…’ or ‘If the invitation is borne by Mr Darcy…’

2 Likes

Body parts count as enclosed, too, for that matter.

1 Like

So perhaps…

To decide if (P - person) lugs the/a/an/-- (T - a thing):
    if T is a part of P or P wears T, no;
    decide on whether or not P encloses T.
1 Like

This will work only for direct incorporation. Probably, you want ‘if P is the component parts core of T and P is not T’

True. And we haven’t even begun to consider the case in which the author has overruled the can’t take other people rule!

1 Like

It’s fun to talk about the general cases, but you shouldn’t get the idea that you need to worry about this in your specific game. You might not have any clothing objects, in which case this isn’t a concern.

For the original question, it might have been sufficient to write:

Definition: an object (called O) is lugged:
	if the player carries O, decide yes;
	if the player carries the satchel and O is in the satchel, decide yes;
	decide no.

This is the crude solution, and you’d have to think about it again if you added a backpack to the game. But crude solutions are fine if they let you get on with writing the game.

2 Likes

A perennially interesting trade-off. They are also bugs-in-waiting.

Much depends on how certain you can be at this point that you’ll not be introducing (in this instance) wearable things, or other carried containers (e.g. a pencil case), or body parts to the game at a later stage, with unexpected consequences…

You crude solution will for example fail if there’s a pencil in a case in the satchel- the pencil will not be ‘lugged’

You can code defensively against this kind of thing by printing a loud and obnoxious error message if the player picks up a container. Or you could write a when play begins loop that checks all the containers in the game to make sure that they are either the satchel or can’t be picked up.