Adventure Book

version 1/110101 by Edward Griffiths

  • Home page
  • Beginning
  • Previous
  • Next



  • Example: ** Lockable Door - How to create a door that can be locked or unlocked from the inside or outside by using an inventory item.

    If we think of an Adventure Book like a traditional piece of interactive fiction, we can imagine certain pages representing the player's current location and his choices taking him from one location to another. We might want an effect where a door is locked and requires a key to open. We may even want to allow him to lock it again with the same key.

    Here's an example implementation of a door that can be locked and unlocked from both the inside and the outside by using the key. Notice how the uses for the key have conditions to sort between when the player is locking or unlocking the door. Notice also how LockedDoor, LockDoor, and UnlockDoor are reused by the pages on either side of the door.

        "Locked Out" by Edward Griffiths
        
        Include Adventure Book by Edward Griffiths
        
        The key is an inventory item.
        
        The First Page is a page.
        "It's seven o'clock in the evening. The dim yellow street lights cast a dismal glow on the slush-covered sidewalk. You stand on your front stoop."
        A choice called tfpa is for The First Page. "Go inside". It triggers GoInside. It requires DoorUnlocked.
        A choice called tfpb is for The First Page. "Go inside". It triggers LockedDoor. It is cancelled by DoorUnlocked.
        A choice called tfpc is for The First Page. "Look under the mat." It triggers FindKey. It is cancelled by the key.
        A use called tfpd is for The First Page. It triggers LockDoor. It uses the key. It requires DoorUnlocked.
        A use called tfpe is for The First Page. It triggers UnlockDoor. It uses the key. It is cancelled by DoorUnlocked.
        
        LockedDoor is a page.
        "You take the doorknob and give it a jiggle. It barely budges, locked tight."
        It is a dead end.
        
        FindKey is a page.
        "You lift the mat and find a small key. Good job no burglars ever think to check."
        It gives the key. It is a dead end.
        
        LockDoor is a page.
        "You turn the key in the lock, locking it tight."
        It removes DoorUnlocked. It is a dead end.
        
        UnlockDoor is a page.
        "You turn the key in the lock, freeing the knob."
        It gives DoorUnlocked. It is a dead end.
        
        GoInside is a page.
        "At last..."
        It is followed by YourHome.
        
        YourHome is a page.
        "Snug and comfortable, the perfect retreat at the end of the day."
        A choice called yha is for YourHome. "Go outside." It triggers GoOutside. It requires DoorUnlocked.
        A choice called yhb is for YourHome. "Go outside." It triggers LockedDoor. It is cancelled by DoorUnlocked.
        A use called yhc is for YourHome. It triggers LockDoor. It uses the key. It requires DoorUnlocked.
        A use called yhd is for YourHome. It triggers UnlockDoor. It uses the key. It is cancelled by DoorUnlocked.
        
        GoOutside is a page.
        "If you must..."
        It is followed by The First Page.