[i7] if item is in (noncontainer)

I ran into a problem while determining whether something was “in” scenery. This is a bit of sloppy coding on my part, by not defining the scenery as a container (“now circuit board is in the recess” is more natural grammar than “now circuit board is part of the recess,” for instance,) but I ran into some confusion beyond then.

I originally expected the following code to say “yay” twice. But it only says “yay” once. It seems like there should be a way to detect that the whosit is in the nonscen-box, and if not, would it be helpful for Inform to throw an error or warning that I’m doing something wrong?

[code]“inscen” by Andrew Schultz

room 1 is a room.

the scen-box is scenery container. the nonscen-box is scenery. the whatsit is a thing. the whosit is a thing.

when play begins:
now whosit is in nonscen-box;
now whatsit is in scen-box.

every turn:
say “[if whosit is in nonscen-box]Yay, whosit is in nonscen-box[else]Boo[end if].”;
say “[if nonscen-box contains whosit]Yay, whosit is in nonscen-box[else]Boo[end if].”;
say “[if whatsit is in scen-box]Yay, whatsit is in scen-box[else]Boo[end if].”;
say “[if scen-box contains whatsit]Yay, whatsit is in scen-box[else]Boo[end if].”;

SHOWME NONSCEN-BOX in fact shows that the nonscen-box contains the whosit. However, the first test fails.

(Note: I also realized I could also say now whosit is part of the nonscen-box and test for that. So it’s good to have Inform allowing multiple ways to work, but I’m still wondering about this case I found which has me confused, whether I’m missing the right phrase or Inform is missing some error checking, or something else is happening.)


The problem is that the whosit is not actually “in” the nonscen-box, as that isn’t a container and thus cannot contain things. If you define it to be a container the problem should go away.

That sounds good, but then, why is it shown as in it with SHOWME? And why doesn’t Inform catch this? By definition, a non-container can’t contain things, but from Inform’s debugging tools, it sort of seems to.

This is sort of nitpicking, but I’m curious as to whether Inform should catch this logic slip, because it has caught when I’ve tried to use properties a certain object type doesn’t have. And if not, it’s definitely frustrating for the programmer to understand they’ve made a mistake.

Try “if whosit is enclosed by nonscen-box”. My understanding (which could be way off) is that being in or on are both the same thing (parent-child relation in the object tree) and the parent’s kind decides which one it actually is. Because the nonscen-box is not a kind that usually contains anything, none of the other relations are true except enclosure which tests for “is child of” in general.

You’re allowed to put whosit in nonscen-box because you might want to define your own relation, like being under or next to or whatever.

Oh, wow, thanks! I forgot about enclosing. I’d used it for people and locations, but not this (more obvious) case.

Thanks for the further explanation, too. It made things click.