Regions containing regions and things, cats and dogs living together

I’m not sure whether I can shed light on the whole issue, but it does have something to do with whether we check this using variables or not.

Compare the handling of “in” as decribed in chapter 6.11 in the docs, 6.11. A word about in.

The test with “let r1 be the Neighborhood;” does not seem to capture the temporary nature adequately.
Because if you add these global variables:

rvar is an object that varies.
mvar is an object that varies.

and then add the following to “when play begins”:

  now rvar is the Neighborhood;
  now mvar is the medallion;
  say "[rvar] [if rvar contains the mvar]contains[else]doesn't contain[end if] [mvar]. Using 'in', [mvar] [if mvar is in rvar]is [else]is not [end if]in [rvar]. Using 'regionally in', [mvar] [if mvar is regionally in rvar]is [else]is not [end if]regionally in [rvar].";

then you will get the following output (because we used variables, similar to the repeat loop):

In general, if you add checks using “in” in your code, like this:

  if the medallion is in the Neighborhood, say "The medallion is in the neighborhood.";
  repeat with obj running through objects begin;
	if obj is a region, say "[obj] [if obj contains the medallion]contains[else]doesn't contain[end if] the medallion. Using 'in', the medallion [if the medallion is in obj]is [else]is not [end if]in [obj]. Using 'regionally in', the medallion [if the medallion is regionally in obj]is [else]is not [end if]in [obj].";
	if obj contains the medallion, say "[obj] contains the medallion.";
  end repeat;

then it will turn out that the results of “contains” match the results of “in”:

(You probably know these posts, but for anyone stumbling over this thread, Dr Peter Bates wrote a very thorough description of the containment (and other) relations in Inform in these posts: Elegant way to test whether something is in a location (even if in a container) - #7 by drpeterbatesuk and Elegant way to test whether something is in a location (even if in a container) - #26 by drpeterbatesuk)

2 Likes