Instead of Going

version 3/071115 by Mikael Segercrantz

  • Home page
  • Beginning
  • Previous



  • Example: *** Printing the Room Description - Creating an activity for printing the room description, which uses the list available exits phrase.

        "Printing the Room Description"

        Include Instead of Going by Mikael Segercrantz.

    We start by declaring the activity.

        Printing the room description is an activity.

        For printing the room description:
            if mode is verbose
            begin;
                say "[description of the location][paragraph break]";
                list available exits, mentioning visited rooms;
            otherwise;
                if mode is brief and the location has not been visited
                begin;
                    say "[description of the location][paragraph break]";
                    list available exits, mentioning visited rooms;
                end if;
            end if.

    Now we need to create the two decision rules referenced above.

        To decide if mode is verbose:
            (- lookmode == 2 -).

        To decide if mode is brief:
            (- lookmode == 1 -).

    And then let us override the standard looking mechanism to use our activity:

        Procedural rule:
            substitute the room description activity rule for the room description body text rule.

        This is the room description activity rule:
            carry out the printing the room description activity.

    And that's it. Now to add a few rooms just to test this out.

        The Driveway is a room. "A driveway, leading up to the house and down south towards the street."

        The Porch is a room. "A simple porch, with a rocking chair in it." It is north of the driveway.

        The Hallway is a room. "A hallway, with a helical staircase on one side." It is north of the porch.

        The Dining Room is a room. "A large dining room, dominated by a massive oaken table." It is east of the hallway.

        The Kitchen is a room. "A kitchen, large enough to supply the large dining room with food." It is east of the dining room.

        The Sitting Room is a room. "A sitting room, with some shelves of books." It is west of the hallway.

        The Upper Hall is a room. "A hallway, leading to the different bedrooms in the house." It is above the hallway.