Forgive me for not including my code here, but It would be a real mess to demonstrate. If someone replies to this thread with a request for it however, I will edit the post to include it. For now, I’ll just explain the problem and see if anyone already knows a simple solution.
I am writing a game where you play as a kid who cannot reach the light switches in the house. You must stand on a supporter in order to reach them. You are being chased by a posessed Teddy bear who tries to kill you when he finds you in a room. He won’t kill you with the lights on, but he will if the lights are off.
Here’s the problem: when the player is standing on the supporter, Inform no longer treats your character as being in the location of the supporter. This took me ages to figure out, and it is messing up my code so much. Every conditional statement involving characters chasing, killing, or otherwise acting on the player must include the qualifier “If X is in the location of the player or if the player is on something (called the target) and X is in the location of the target…” And it’s just a nightmare. Does anyone know a simple solution to this or is my fate sealed?
I agree with @mirality, enclosed by is great for this and for everything else (‘enclosed by the player’ is better than ‘carried by the player’, since it covers things in containers and holdalls, etc.). It should be the easiest way to fix your code!
If I understand you correctly, your problem was with the condition ‘if the player is in X’, which, perhaps counter-intuitively, will be true only if :
(i) X is a room that is the (player’s) location and the player is neither on a supporter or in a container OR
(ii) X is a container that the player is immediately within (i.e. without any intervening containers or supporters)
(i) works this way because is in implies the containment relation and, counter-intuitively, Inform does not consider something on a supporter to be contained by a container of the supporter. This is because to Inform, in the same way an object cannot be both a container and a supporter, an object cannot be both contained and supported at the same time. So, a candle on a cake in a box is not in or contained by the box… Nor, for that matter, is a cherry that is in the cake, since something is only in something that immediately contains it, i.e. without intervening supporters or containers. As stated elsewhere is enclosed by works however, through any hierarchy of supporters and/or containers. So, the location encloses the player is always true.
Conversely, the location will always be the room that the player is within (or in the case of the location of X, the room that X is within).
So, somewhat confusingly, although the location of the player doesn’t change when the player gets onto a supporter, ‘the player is in the location’ changes from true to false: indeed the player becomes ‘in’ neither the location or the supporter (she is ‘on’ the latter).
Furthermore, if your story file is getting cluttered with multiple repeats of the same complex condition, like this, consider defining a simple shorthand for it like so:
To decide if (X - a thing) is co-located with (Y - a thing):
if the location of X is the location of Y, yes;
This enables you to write ‘If the killer bear is co-located with the player…’ etc.
Or, even simpler, if you’re only interested in co-location with the player:
Definition: A thing is in the vicinity if the location of it is the location.
Now you can say things like ‘If the killer bear is in the vicinity…’
Having said all that, for your particular example, if we can assume that the killer bear will never be on a supporter or in a container, without any of these complications your condition can be simply reduced to ‘If the killer bear is in the location…’
… or if the killer bear might be in a container or on a supporter, ‘If the killer bear is enclosed by the location…’
Because as noted above, the location (of the player) does not change if the player gets onto a supporter, the second half of your example condition is redundant- if X is in the location of the supporter then X must also be in the location (of the player).
An interesting and largely undocumented discovery I made today was that Inform actually already provides a relation linking an object to its location, listed in the Index as the room-containment relation.
Interestingly, in the Standard Rules there is no verb defined for this relation- but that is easily fixed:
The verb to locate means the room-containment relation.
The verb to be located in means the reversed room-containment relation.
Now you can also write, for example:
If the location locates the killer bear...
but perhaps more naturally:
If the killer bear is located in the location...
If the killer bear is located in the Kitchen...
which may seem marginally more natural than ‘If the location of the killer bear is the Kitchen…’ etc.