Newbie Question: Default region mechanism?

Hello,
Just starting to explore the mysteries of Inform 7. Sorry if the question is too easy.

If I want to create a region with a large number of rooms in it,
is there a way to avoid writing the region name again and again?

ie. Instead of:

R is a region
A is a room in R. …
B is a room in R. …
S is a region in R. …
etc.

I would like to write something like:

R is a region.
Begin Region R.
A is a room. …
B is a room. …
S is a region. …
etc.


End Region R.

… and have everything (rooms and regions) between begin and end default as belonging to region R.

From what I have seen of the language so far I suspect there aren’t any
Begin - End statements, but maybe there is some other mechanism to achieve
the effect I want.
TIA

No, there’s no shortcut for this.

[code]“Region” by Ned

X is a region. room 1, room 2, room 3 and room 4 are rooms in X.

Y is a region. room 5 is a room in Y. room 5 is north of room 1.

every turn:
say “[map region of location of player]”[/code]

This isn’t much of a shortcut, and it doesn’t use anything formal like “begin” or “end,” but it seems to work decently enough for me. The drawback is that if you mistype a room when you define it later, you wind up with parallel rooms.

If the rooms really start to sprawl, you may want to define an action so

repeat with Q running through rooms: say "[Q] is in [map region of location of player]."

To make sure you’ve taken care of everything.

The idea was to be able to copy and paste in example code from other sources,
perhaps dozens of lines of code, complete with rooms, descriptions, sceneries,
backdrops, directions, events and what not and just bundle them all together in
a region of their own.

I guess there isn’t anything for this then. It’s kind of hard to believe that it
would be this limited. doh!

You can do something like this.

[code]“Test”

When play begins:
now the left hand status line is “[map region of the location]”;
now the right hand status line is “[player’s surroundings]”.

Room 00 is A Room. Room 01 is east of Room 00. Room 02 is east of Room 01. Room 03 is east of Room 02. Room 04 is south of Room 00 and southwest of Room 01. Room 05 is south of Room 01, southeast of Room 00, southwest of Room 02 and east of Room 04. Room 06 is south of Room 02, southeast of Room 01, southwest of Room 03 and east of Room 05. Room 07 is south of Room 03, southeast of Room 02 and east of Room 06. Room 08 is south of Room 04 and southwest of Room 05. Room 09 is south of Room 05, southeast of Room 04, southwest of Room 06 and east of Room 08. Room 10 is south of Room 06, southeast of Room 05, southwest of Room 07 and east of Room 09. Room 11 is south of Room 07, southeast of Room 06 and east of Room 10. Room 12 is south of Room 08 and southwest of Room 09. Room 13 is south of Room 09, southeast of Room 08, southwest of Room 10 and east of Room 12. Room 14 is south of Room 10, southeast of Room 09, southwest of Room 11 and east of Room 13. Room 15 is south of Room 11, southeast of Room 10 and east of Room 14.

Region A is A Region. Region B is A Region. Region C is A Region.

Room 00, Room 01, Room 02, Room 03, Room 04, Room 05, Room 06 and Room 07 are in Region A.

Room 08, Room 09, Room 10, Room 11, Room 12, Room 13, Room 14 and Room 15 are in Region B.

Region A and Region B are in Region C.[/code]

You can also also mix rooms and regions when defining as well, like so.

A is A Room. B is A Room. Region S is A Region. Region R is a region. Room A, Room B and Region S are in Region R.

Hope this helps.

Wait! I am wrong! You can do this:

R is a region.
An R-Room is a kind of room.
All R-Rooms are in R.

The Kitchen is an R-Room.
The Bathroom is an R-room.

(I missed it the first time because I tried “An R-Room is always in R,” which doesn’t work, although I’m not sure why.)

This doesn’t fulfil your desire for a cut-and-paste solution – you still have to change the declaration of each room – but it’s shorter.

As Zarf pointed out, there may be a way, but I’m not sure I’d recommend your idea of pasting from other systems.

I mean, maybe if you compiled the game after every addition, but Inform is finicky enough - to introduce text from other environments is inviting bugs.

Well, you can like copy in like, room descriptions and so on, but I’d be careful about this idea if I were you.

Thanks zarf. That one comes close. Then all I need is a simple text substitution from “room” to “R-room” in the text before pasting it in, and check through it to leave “room” inside text strings alone. I can probably live with that.

But will it work for regions as well as for rooms?

Thanks for the advice duodave. At the moment I’m using this to paste in example snippets from the manual as I explore the documentation - ie. I can wander around among several of the examples from the manual, all within the same game and want to keep track of which one I’m in by having each in its own ragion. In that setting I’m not too worried about bugs, it’s just playing around anyway.

If I understand you right though, it’s the dangers of pasting from other games you are warning against, not this default-region mechanism as such, right?

Even though it’s just for a bit of fun now, I can see myself wanting this kind of solution for real too later on, if I want to, say, create a geography with different countries with varying numbers of locations in each country.

Can anyone tell me, will the following work?

USA is a region.
A US-state is a kind of region.
All US-states are in USA.

New York is a US-state.
An NY-location is a kind of room.
All NY-locations are in New York.

New York City is an NY-location.
Albany is an NY-location.
Rochester is an NY-location.
etc.

I guess from the above discussion that it definitely will if I change the second line to:
A usstate is a kind of room.
But does “kind of region” also work?

Oh well, I’ll test this as soon as I can anyway, but maybe there are more comments or tricks around this.
I’d love to hear them.

Right. If you have say, a game written in Alan or TADS and try to redo it in Inform 7, you may introduce hard-to-find bugs if you just paste stuff in.

Oh, and regions can’t overlap (although I wish they could). So you can’t say, have a region called “indoors” that includes a bunch of rooms and then have a second region called “bedrooms” that includes some of the indoor rooms.

You, can, however, give qualities to rooms and then refer to rooms of that quality, which for most purposes can be used in much the same way.

So, instead of having a region called The Outdoors and saying “Instead of disrobing in the Outdoors…”, you could give rooms an outdoors adjective (“A room is can be outdoors or indoors”) and then check the adjective instead: “Instead of disrobing in an outdoors room…”

Actually, you can have nested regions like you describe, but the regions must be completely inside each other. You can have bedrooms that are all also indoors, but none of the bedrooms can be outdoor rooms.