Adventure Book

version 1/110101 by Edward Griffiths

  • Home page
  • Beginning
  • Previous
  • Next



  • Example: ** Adaptive Text - How to change what's written on a page based on the game state.

    In the original Adventure Book system, every page had a single, static description. One major advantage of using Inform 7 is that you can vary the way a page is written based on how flags are set and whether inventory items are carried. This can be very useful if you have a story where the player visits the same page many times, but it looks slightly different or slightly different things happen based on what has happened previously.

    In this very simple example, the description of the cat varies depending on whether the player is holding the cat treats.

        "Cat Feeder" by Edward Griffiths
        
        Include Adventure Book by Edward Griffiths
        
        The treats is an inventory item.
        
        The First Page is a page.
        "You're standing in your kitchen. [if the treats is off]Your cat paces the room, bored and inattentive.[otherwise]Your cat has crossed the room to meet you, stroking itself against your ankles lovingly.[end if]".
        A choice called tfpa is for The First Page. "Get out a box of cat treats." It triggers GetTheTreats. It is cancelled by the treats.
        A use called tfpb is for The First Page. It triggers FeedYourCat. It uses the treats.
        
        GetTheTreats is a page.
        "You open the drawer and pull out one of the boxes of cat treats."
        It gives the treats. It is a dead end.
        
        FeedYourCat is a page.
        "Your cat happily devours every last treat from your hands, one by one. Your usefulness spent, it returns its attention to personal matters."
        It removes the treats. It is a dead end.