Alright. Slightly different solution than I saw above. Sorry for the wall of code below.
This is a complete program (if you copy it into Inform, it will run). There are a ton of comments so that things make sense. Basically, I have a couple of ‘template’ rooms. To store map connections, I have a table at the bottom (right now it only stores n/s/e/w). That can be expanded to also include descriptions for each room. Then I store a location ID to keep track of which copy of the template room you’re in. Finally, I override going so that I use my table instead of the normal rules governing movement.
If you play around with this, “build” is a command that will create a new Copy Room to the north of where you are (if there’s not a room there, and if there’s room in the table).
There’s a lot of expanding to be done, but this is the base framework for a relatively dynamic game. It’s not infinite, but it can seem that way, and it works with Z-Machine.
If you need it larger, just add more blank rows.
[code]“Room System Testing” by SanKeshun
Part 1 - Normalish Bits
Start Room is a room. “This is the room you start in.[connection description]”.
North Room is a room. “This is the room to the north.[connection description]”. North Room is north of Start Room.
Copy Room is a room. “You are in copy room [location ID].[connection description]”.
Part 2 - Stuff to Make Moving Work
Section 1 - Global Variables
Location ID is a number that varies. Location ID is initially 0.
Highest location ID is a number that varies. Highest location ID is initially 4. [This changes for a larger or smaller map. For auto-generated maps, start at 0 and increment it as you build]
Connection description is a text that varies. Connection description is initially “”.
To update the connection description:
now connection description is “[line break]”;
if Location ID is an ID listed in Table 1:
if there is a North entry:
now connection description is "[connection description][the printed name of North entry] is to the north. ";
if there is a East entry:
now connection description is "[connection description][the printed name of East entry] is to the east. ";
if there is a South entry:
now connection description is "[connection description][the printed name of South entry] is to the south. ";
if there is a West entry:
now connection description is "[connection description][the printed name of West entry] is to the west. ";
if connection description is “[line break]”:
now connection description is “”;
otherwise:
say “Something is seriously wrong; you’re not where you should be.”
When play begins: update the connection description.
Section 2 - Fixing Going
[First we allow ourselves to move even if Inform can’t see the connection]
The determine map connection rule is not listed in the check going rulebook.
The can’t go that way rule is not listed in the check going rulebook.
[Check out the map (below) if this bit doesn’t make sense]
Instead of going:
if Location ID is an ID listed in Table 1:
let D be the noun;
let saveNum be location ID;
[say “Beginning move in direction [D].”;]
if D is north:
if there is a North entry:
now location ID is the NID entry;
[say “Beginning qing…”;]
try qing;
otherwise:
say “You cannot go that way (Spot A).” instead;
now location ID is saveNum;
if D is east:
if there is a East entry:
now location ID is the EID entry;
[say “Beginning qing…”;]
try qing;
otherwise:
say “You cannot go that way (Spot B).” instead;
now location ID is saveNum;
if D is south:
if there is a South entry:
now location ID is the SID entry;
[say “Beginning qing…”;]
try qing;
otherwise:
say “You cannot go that way (Spot C).” instead;
now location ID is saveNum;
if D is west:
if there is a West entry:
now location ID is the WID entry;
[say “Beginning qing…”;]
try qing;
otherwise:
say “You cannot go that way. (Spot D)” instead;
now location ID is saveNum;
[say “New move is done.” instead;]
otherwise:
say “New move has issues! That room doesn’t exist!” instead.
Section 3 - Qing (or, the Extra-Fiddly Bits)
Understand “kikuvashtu” as qing. [these are random and made up; they mean nothing][it’s pronounced “queueing”]
Qing is an action applying to nothing.
Check qing: [Although, I think this is already safeguarded against. Whatever]
if there is no Base Room corresponding to an ID of location ID in Table 1, say “That room does not exist.” instead.
Carry out qing:
update the connection description;
move the player to the Base Room corresponding to an ID of location ID in Table 1; [locationID has been updated by this point]
[say “The player has now been moved to [the Base Room corresponding to an ID of location ID in Table 1].”;]
let theCurrentLocation be location; [Does this seem stupid? If you say yes, you’re wrong. It fixed some of my bugs. I don’t know how.]
choose row with ID of location ID in Table 1;
if there is a North entry:
now theCurrentLocation is mapped south of the North entry;
[say “Now [theCurrentLocation] is mapped south of [the North entry].”;]
if there is a East entry:
now theCurrentLocation is mapped west of the East entry;
[say “Now [theCurrentLocation] is mapped west of [the East entry].”;]
if there is a South entry:
now the location is mapped north of the South entry;
[say “Now [theCurrentLocation] is mapped north of [the South entry].”;]
if there is a West entry:
now the location is mapped east of the West entry. [if you uncomment the says, change that period to a semicolon]
[say “Now [theCurrentLocation] is mapped east of [the West entry].”;]
[say “Successfully carried out setting the room.”]
Section 4 - Building New Rooms
Understand “build” as building.
Building is an action applying to nothing.
Check building:
choose the row with id of location ID in Table 1;
if there is a North entry, say “There’s no room!” instead;
if the number of blank rows in Table 1 is 0, say “You have insufficient materials; you’ll need to destroy a building (which you can’t do).” instead.
Carry out building:
now highest location ID is highest location ID + 1;
choose a blank row in Table 1;
now Base Room entry is Copy Room;
now ID entry is highest location ID;
now South entry is the location;
now SID entry is location ID;
choose the row with id of location ID in Table 1;
now North entry is Copy Room;
now NID entry is highest location ID;
update the connection description.
Report building:
say “You build a new room to the north! Huzzah!”.
Section 5 - The Map
Table 1 - Map
Base Room ID North NID East EID South SID West WID
Start Room 0 North Room 1 Copy Room 2 Copy Room 3 Copy Room 4
North Room 1 – -- – -- Start Room 0 – --
Copy Room 2 – -- – -- – -- Start Room 0
Copy Room 3 Start Room 0 – -- – -- – --
Copy Room 4 – -- Start Room 0 – -- – --
with 10 blank rows[/code]