Different backdrop descriptions based on region

I have multiple regions, and each region has a similar backdrop. Say, of the sky:

The Forest is a region.
The sky is a backdrop in the Forest. "Clear and blue, with a few fluffy clouds. The sun is shining."
The City is a region.
The stormy sky is a backdrop in the City. "The sky is dark and overcast, and it's raining heavily. Occasionally you see a flash of lightning."

Now I want to add different “aliases” for this backdrop. For the Forest, I want something like Understand "cloud" and "sun" as the sky., while for the City I want to also understand “rain” as the sky. What’s the best way to achieve that? Thanks!

Edit: I realize that perhaps this example is a bit silly, and that the best thing to do here might be to have separate sky, sun and rain backdrops… But in the general case, is there a more elegant solution?

Well, notice that you’ve actually got two different backdrops, both of which have “sky” as (part of) their name. This has several potentially confusing implications. One is that it may confuse you as you’re writing; another is that Inform could become confused when compiling. It might be easier to change the name of the first declaration to the clear sky, or something similar, to help resolve those ambiguities.

But as-is, with two different “sky” backdrops, it looks like there’s no need to do anything special to separate out the aliases: unless the City is regionally in the Forest, or unless you’re explicitly messing with scope, only one of those “sky” objects will be in scope at a time, so if the player types x sky in the Forest, only the clear-sky object will be found, whereas the same command in the City will find only the stormy sky.

If what you really want is to have a single sky backdrop that’s above everything, but to alter its characteristics as the player moves around, there are several ways to do that.

One might be to make sun and rain and clouds objects part of the “sky” backdrop that’s over everything. This might be handy if you want the player to be able to refer to the sun and the clouds separately from the sky itself, perhaps to provide individualized descriptions. You can remove them as necessary with declarations like now the sun is part of the sky or now the clouds are not part of the sky. These changes could be part of starting/stopping recurring scenes, or movement rules, or every turn rules. You could also arrange for the description of the sky object itself to depend on what’s currently part of it: The description of the sky is "[if the sun is part of the sky]Clear and blue, with a few fluffy clouds[otherwise if the clouds are part of the sky]Dark and overcast, and it's raining[otherwise]Black as midnight in a coal mine[end if].".

This has the benefit of creating actual objects for the parser to find and deal with in the standard manner so that you don’t have to muck around with aliasing the individual object to the sky backdrop and then including the object’s description as part of the larger backdrop’s description.

But if you really do just want to have some aliases work in some parts of the simulated world, that’s easy enough with an understand [...] when [...] rule:

Understand "cloud" and "sun" as the sky when the player is regionally in the Forest.

should do it, though, again, if you’re defining two separate sky objects, you shouldn’t need the when clause in the first place; you could just do this:

Understand "cloud" and "clouds" and "sun" as the sky.
Understand "rain" as the stormy sky.

Sorry, misread what was intended

Thank you! Definitely a case of me overthinking things, hehe. Works like a charm once I reorganized things a little.

1 Like