Dynamic Rooms

version 1 by Aaron Reed

  • Home page
  • Beginning
  • Next



  • Documentation


    With this extension, you can easily create and destroy new rooms during play. While this is technically possible with Jesse McGrew's "Dynamic Objects," the method here is simpler, customized for rooms, and available for both z-code and Glulx.

    The extension works by creating a reserve of empty rooms when the game first begins and swapping them in and out as needed. The author must declare the maximum number of dynamic rooms that will be needed:

        There are 50 dynamic rooms.

    This statement should appear *after* you define your initial starting room (unless you explicitly move the player when play begins). Also note that you can only define 100 duplicates at once, but for more, you could chain a series of definition statements. (Repeating the above statement three times would produce 150 dynamic rooms.) Note, though, that large numbers of dynamic rooms will start to slow down your game considerably.

    Before creating a new room, you need to check whether there are any unused rooms left. You can use the phrase:

        if out of dynamic rooms

    Or perform more elaborate calculations by checking the number of:

        available dynamic rooms
        used dynamic rooms

    To create a new room, you must give it a printed name and assign it to an object variable:

        let excavation be a newly created room with name "Cave";

    By default, the new room will have no entrances or exits. For convenience, you can instead create a room with a reciporical exit connecting to any existing location via the shortcut phrase:

        let excavation be a newly created room east of location with name "Cave";

    To destroy a room:

        dissolve excavation;

    This will remove any exits to or from the room and un-name it; you must account in your own code for the possibility that the player might be in the dissolved room when this happens, otherwise she would be trapped there.