Glimmr Automap

version 2/101030 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Example: ** Automapping the Manse - By default, Glimmr Automap responds to mouse input on a room in the map by displaying a "tooltip" that shows the printed name of the room clicked on. However, we may also want to do other things with mouse input to the map, such as moving to the room clicked, or displaying what the player knows about the room, or something different altogether. In this case, we can either deactivate the query functionality altogether, or activate the query button, which allows the player to move between query and custom modes. The latter is the approach taken in this example, which borrows the "going to a room" code from the Inform manual's "Misadventure" example (number 295). Clicking on a room will issue a command to go to that room.

    We begin by setting up things more or less as in the previous example. Note, however, the first when play begins rule, which adds the query button (the UI-query g-element) to the toolbar. As explained above, when the query button is present, it must be activated in order for clicking on a room to act as a query. Otherwise, nothing will happen--or we can add our own behavior, as we will do here.


        "Automapping the Manse"

        Include Glimmr Automap by Erik Temple.
        Include Glimmr Automap Tileset by Erik Temple.
        Include Glimmr Bitmap Font by Erik Temple.

        [Before looking for the first time:
            say "This is a small example for Glimmr Automap, a graphical front-end to Mark Tilford's Automap extension. It generates a map as the player explores the world of the game, with very little effort needed on the part of the author.

        This example for the Glimmr Automap extension adds new behavior to our procedurally generated map. Clicking on a room in the map will now produce the command GO TO <ROOM>. To query the map about the name of a room, press the ? button, then click on the room you wish to query. Zoom the map by using the + and - buttons."]
        
        Use automap hide paths through closed doors.

        The map-window is a map-display window spawned by the main-window. The position is g-placeabove. The measurement of the map-window is 50. The associated canvas of the map-window is the map-canvas.

        The map-canvas is a g-canvas. The associated canvas of a g-element is the map-canvas.

        When play begins:
            follow the opening up the map window rules.

        The display status of UI-query is g-active.

    The primary map hyperlink mode is defined next, using the "go to any room" code from the Misadventure example in the Inform documentation. The only automap-specific code is the automap graphlink rule at the end of the block, which deals with mouse input to a room, issuing the command "GO TO <ROOM>" on behalf of the player.

        Understand "[any room]" as going by name. Understand "go to [any room]" as going by name.

        Going by name is an action applying to one thing.

        Check going by name:
            if the noun is the location, say "You're already in [the location]." instead;
            if the noun is not adjacent and the noun is unvisited, say "That noun did not make sense in this context." instead.

        Carry out going by name:
            let aim be the best route from the location to the noun, using doors;
            if aim is not a direction, say "You can't think how to get there from here." instead;
            say "(heading [aim])[command clarification break]";
            try going aim;
            if the location is not the noun, say "You'll have to stop here."
        
        Automap graphlink rule for a room (called the target):
            let target-text be the printed name of the target in upper case;
            change glulx replacement command to "GO TO [target-text]";
            exit.

    And now we provide a geography to move around in:
        

        The Front Lawn is south of the Porch.

        The East Lawn is northeast of the Front Lawn. The West Lawn is northwest of the Front Lawn.

        The Rear Lawn is northwest of the East Lawn. Southwest of the Rear Lawn is the West Lawn.

        The front door is a closed door. It is inside from the porch and outside from the Foyer. "The front door is [if the front door is open]open[otherwise]closed[end if]."

        The Dining Room is east of the Foyer. The Living Room is west of the Foyer. The Kitchen is north of the Dining Room. Bottom of the Stairs is north of the Living Room.

        The Hallway is east of Bottom of the Stairs, north of the Foyer, and west of the Kitchen.

        Top of the Stairs is up from Bottom of the Stairs. Master Bedroom is east of Top of the Stairs. Master Bath is east of the Master Bedroom. West Hall is south of Top of the Stairs. East Hall is east of West Hall and south of the Master Bedroom. East of East Hall is Front Bedroom.

        A tree is scenery in Rear Lawn. "Looks climbable." Instead of climbing the tree: try going up.

        Up from the Rear Lawn is Treetop. "A tall tree grows here. Large branches scrape against the house." The description of Treetop is "You could climb into the house through the window. Type IN."

        A window is an open door. It is not openable. "The window is open." The window is inside from the Treetop and outside from the Master Bedroom.

    This final sentence may look like it is merely testing a condition, but in fact this is the Automap extension's means of mapping a room to a specific location. Effectively, the first half of the statement tells Inform to try to place the Master Bedroom 1 unit (1 room, basically) south of the Treetop. If the automapper is unable to do so, the error message will be printed.

        Before constructing the status line:
            unless Master Bedroom is placed 0 and 1 from Treetop, say "*** Error placing Treetop ***".