Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
Tutorial explaining how to use the AdventureJS hintcard methods. tutorial, hintcard methods

Goals, Hints, and Scores:Hintcards

Hintcards are a system for creating and displaying hints to the player. Hints are managed through a combination of author actions and system automation: it's up to authors to define and activate hints; while the HintManager tracks which hints have been revealed by the player. The first thing an author needs to do is create a set of hints via shorthand or longhand methods. A player might see something like the following in response to typing hints:

example output

HINTS

Welcome to the hints for my awesome game.
The Sandstorm5
How do I survive the sandstorm?
1. Have you tried to find shelter?
What...
Where...
Why...
How...

Methods

  • MyGame.hintcard.set({}) {Object} an object containing hint definitions MyGame.hintcard Use this to add goal data to the hintcard.
    Expand for example
    MyGame.hintcard.set({
      introduction: `These are my hints. `,
      hints: {
        "The Sandstorm": {
          text: "You're lost in the sandstorm. ",
          active: true,
          hints: {
            1: `Who...`,
            2: `What...`,
            3: `Where...`,
            4: `Why...`,
            5: `How...`,
          },
        },
      },
    });
  • MyGame.hintcard.activateHint("my hint") {String} name - the name of a hint {Boolean} recurse - whether to recursively apply to nested hints. Default is true. Boolean - true on success, false on failure Use this to activate a hint, and optionally any nested hints.
    Expand for example
    MyGame.gamecard.activateHint("my hint");
  • MyGame.hintcard.deactivateHint("my hint") {String} name - the name of a hint {Boolean} recurse - whether to recursively apply to nested hints. Default is true. Boolean - true on success, false on failure Use to deactivate a hint, and optionally any nested hints. Use it like this.
    Expand for example
    MyGame.gamecard.deactivateHint("my hint");

Properties

Hint Properties

Hints fall into two types: individual hints and hint groups, though they are both the same kind of object, only distinguished by the values of their properties. If a hint has nested hints in hint.hints, it automatically becomes a group. If it's a group, hint.name will be displayed as a title and hint.text as a subtitle. If it's an individual hint, hint.text will be the body of the hint.

  • MyGame.hintcard["my hint"].name {String} hint.name is only used for hint groups, and is set automatically by using the provided object key. Group names are presented as group titles in the hints window. A group's name is also its object key, and can be used with methods such as game.hintcard.activateHint("my hint group").
    Expand for example
    MyGame.hintcard.set({
      introduction: `Welcome to the hints for my awesome game. `,
      hints: {
        "Chapter 1": {
          active: true,
        },
      },
    });
    
    MyGame.gamecard.activateHint("Chapter 1");
        
  • MyGame.hintcard["my hint"].text {String} hint.text has two different uses. If the hint is a group, hint.text is an optional property that, if provided, will be used as a subtitle above the group list in the hint window. Otherwise, the text will be used as the body of the hint.
    Expand for example

    This example shows hint.text being used as the subtitle of a hint group.

    MyGame.hintcard.set({
      introduction: `Welcome to the hints for my awesome game. `,
      hints: {
        "Chapter 1": {
          active: true,
          text: "In which our hero explores the castle. ",
        },
      },
    });
        

    This example shows hint.text being used as the hint itself. For individual hints, be sure to number them as you see here. The numbers get converted into property keys, which are used for tracking which hints have been revealed by the user.

    MyGame.hintcard.set({
      introduction: `Welcome to the hints for my awesome game. `,
      hints: {
        "Chapter 1": {
          active: true,
          text: "In which our hero explores the castle. ",
          hints: {
            "The Wizard's Bedroom": {
              active: true,
              text: "In which our hero explores a magical boudoir.",
              hints: {
                active: true,
                text: "Does the wizard need a housekeeper?"
                1: "Have you tried looking in the closet?",
                2: "Have you tried looking in the chest?",
                3: "Have you tried looking in the desk?",
              },
            },
          },
        },
      },
    });
        
  • MyGame.hintcard["my hint"].hints {String} hint.hints optionally contains a nested list of hints. If a hint has nested hints, that makes it a hint group. This is the main thing that distinguishes a hint from a hint group. Nested hints have the same structure as top level hints and can contain deeper nests.
    Expand for example
    MyGame.hintcard.set({
      introduction: `Welcome to the hints for my awesome game. `,
      hints: {
        "Chapter 1": {
          active: true,
          text: "In which our hero explores the castle. ",
          hints: {
            "The Wizard's Bedroom": {
              active: true,
              text: "In which our hero explores a magical boudoir.",
              hints: {}
          },
        },
      },
    });
        
  • MyGame.hintcard["my hint"].active {Boolean} hint.active is a boolean used to determine whether a hint group should be shown in the hint window. Inactive hint groups are hidden from players. Hints are defined as active by default. Authors can change this during the game through the use of game.hintcard.activateHint("my hint") and game.hintcard.deactivateHint("my hint").
    Expand for example
    MyGame.hintcard.set({
      introduction: `Welcome to the hints for my awesome game. `,
      hints: {
        "Chapter 1": {
          active: true,
          text: "In which our hero explores the castle. ",
          hints: {
            "The Wizard's Bedroom": {
              active: true,
              text: "In which our hero explores a magical boudoir.",
              hints: {
                active: true,
                text: "Does the wizard need a housekeeper?"
                1: "Have you tried looking in the closet?",
                2: "Have you tried looking in the chest?",
                3: "Have you tried looking in the desk?",
              },
            },
          },
        },
      },
    });
    
    MyGame.gamecard.activateHint("The Wizard's Bedroom");
    
    MyGame.gamecard.deactivateHint("The Wizard's Bedroom");
    
    
  • Private-ish Properties

    The following properties are not technically private, as AdventureJS has no private properties. We point these out because, while authors shouldn't need to access them directly, we can imagine situations where authors might want to.

  • MyGame.hintcard["my hint"].revealed {Boolean} hint.revealed is a boolean used to determine whether a hint has been revealed by the user. Authors shouldn't typically need to set this as it is handled by the HintManager in response to user actions, but authors can manually reveal hints through the use of game.hintcard.revealHint("my hint").
    Expand for example
    MyGame.hintcard.set({
      introduction: `Welcome to the hints for my awesome game. `,
      hints: {
        "Chapter 1": {
          active: true,
          text: "In which our hero explores the castle. ",
          hints: {
            "The Wizard's Bedroom": {
              active: true,
              text: "In which our hero explores a magical boudoir.",
              hints: {
                text: "Does the wizard need a housekeeper?"
                1: "Have you tried looking in the closet?",
                2: "Have you tried looking in the chest?",
                3: "Have you tried looking in the desk?",
              },
            },
          },
        },
      },
    });
    
    MyGame.hintcard.revealHint("The Wizard's Bedroom");