Objects in dynamic rooms?

I have the extension dynamic rooms by Aaron Reed. I was able to generate a random map based on the coordinates of the starting room. Howver, I am puzzled by how to add dynamic rooms to a region, how to place objects in dynamic rooms, and how to give drynamic rooms a description.

All help is appreciated.

These issues all seem to boil down to not knowing how to refer to a dynamic room that you’ve created. This depends on the details of your code, but typically you’d manipulate the room immediately after creation, store a reference to the room somewhere for later use, or else refer to it via a description (“let R be the room west from the Bedroom”).

The examples in the extension’s docs look like “Let foo be a newly created room …” or “now foo is a newly created room …” They’re storing a reference to the room in a variable. So, if you want to manipulate the newly created room, you’d use that variable to refer to it: now foo is in MyCoolRegion; now the scary robot is in foo; now the description of foo is “My awesome room description.”

Note that let creates a local variable, so you’d have to do your room manipulation within the scope of that local variable (i.e., inside the same rule in which it’s defined) unless you store a copy of the reference somewhere more permanent or access it later via a description.

If you need more detailed help and want to post a code snippet, I’d be happy to take a look at it.

This is what I have, its pretty basic:

[code]Starting Room is a room.

When play begins: locate Starting Room at xyz {0, 0, 0}; assign xyz coordinates based on Starting Room.

There are 20 dynamic rooms.
[/code]

Ok, well it looks like you’ve created a normal room called Starting Room and assigned the coordinates (0,0,0) to it. You’ve set up the extension to assign coordinates to new dynamic rooms based on their relative positions to Starting Room, and you’ve also created a pool of 20 dynamic rooms that can be allocated. However, you haven’t actually allocated any dynamic rooms out of this pool yet.

Here’s an example of allocating and freeing rooms:

Include Dynamic Rooms by Aaron Reed.

Definition: a direction (called thataway) is viable if the room thataway from the location is a room. [From WwI example 102: Bumping into Walls]

Starting Room is a room. "This is a nondescript room[if the number of adjacent rooms is 1]. There is an exit to the[else if the number of adjacent rooms > 1]. There are exits to the[end if][if the number of adjacent rooms > 0] [list of viable directions][end if]."

When play begins:
	locate Starting Room at xyz {0, 0, 0};
	assign xyz coordinates based on Starting Room.

There are 20 dynamic rooms.

[I didn't have any luck with dynamic membership of rooms in regions, so this is a workaround. We can write rules about jumpy rooms or wavy rooms.]
A room can be jumpy. A room is usually not jumpy.
A room can be wavy. A room is usually not wavy.

The duck is an animal.
The rabbit is an animal.

After jumping when the location is Starting Room and the room north from Starting Room is nothing and available dynamic rooms > 0:
	let rm be a newly created positioned room north of Starting Room with name "Jumpy Room";	
	say "You leap into the air and feel a surge of power";
	if rm is Starting Room, instead say ", but nothing happens.";
	now rm is jumpy;
	if the duck is nowhere, now the duck is in rm;
	now the description of rm is "This is a small room with a damp floor. The Starting Room is back to the south. The coordinates are: ([x-coordinate],[y-coordinate],[z-coordinate]).";
	say ". The north wall melts into nothingness, revealing a room beyond."

After waving hands when the location is Starting Room and the room east from Starting Room is nothing and available dynamic rooms > 0:
	let rm be a newly created positioned room east of Starting Room with name "Wavy Room";
	say "You wave your hands and feel a surge of power";
	if rm is Starting Room, instead say ", but nothing happens.";
	now rm is wavy;
	if the rabbit is nowhere, now the rabbit is in rm;
	now the description of rm is "This is a small room with a grassy floor. The Starting Room is back to the west. The coordinates are: ([x-coordinate],[y-coordinate],[z-coordinate]).";
	say ". The east wall melts into nothingness, revealing a room beyond."
	
The block sleeping rule is not listed in the check sleeping rulebook.

Instead of sleeping when the location is the Starting Room, say "[We] [aren't] feeling especially drowsy."

Definition: a thing is nonplayer if it is not the player.

After sleeping when the location is not Starting Room:
	say "You drift off to sleep, and [the location] dissolves around you. You wake to find yourself in...";
	now all nonplayer things in the location are in the Starting Room;
	now the location is not jumpy;
	now the location is not wavy;
	[We need to remove the room from the coordinate system manually, since dissolve doesn't do it. If we don't, we'll get the same room object back when we try to allocate a new room at that same position, but it won't be initialized properly.]
	now the location is absent from the coordinate system;
	dissolve the location;
	now the player is in the Starting Room.
	
Test me with "n / jump / l / jump / n / wave / s / e / wave / l / wave / e / sleep / e / wave / l / e".

As I mentioned in the comments, I wasn’t able to get dynamic membership of a room in a region to work. “now rm is in TestRegion” produces a compile error, while “move rm to TestRegion” compiles, but produces a runtime error complaining that rm is not a backdrop. So, my example above of “now foo is in MyCoolRegion;” was bogus. Sorry about that. As a workaround, I’ve given the rooms either-or properties representing membership in regions.