Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
Tutorial explaining how to work with basic descriptions in AdventureJS. tutorial, basic descriptions

Customize Output:Basic Descriptions

You can describe anything and everything in AdventureJS. There's a simple, basic way to apply descriptions to things – and a lot of much more complex ways. For now, we're going to stick to simple descriptions, using the asset.description property.

Describe a Room and the things in it

MyGame.createAsset({
  class: "Room",
  name: "Inner Sanctum",
  description: `It feels like days since you entered The Dungeon. You've sprung all the traps, won all the battles, answered all the riddles, retrieved your items from the thief, and finally arrived here, at the inner sanctum. After years of questing, your goal is finally within reach. You clench your fist around the melted brass key that hangs by a fine chain around your neck. `,
});

MyGame.createAsset({
  class: "Key",
  name: "melted brass key",
  place: { in: "Hero" },
  description: `It's a small key, made of brass. It's scarred and a bit melted from some unknown incident, but the teeth appear intact. You've carried it since it was given to you by your father. `,
});

MyGame.createAsset({
  class: "Chest",
  name: "battered chest",
  place: { in: "Inner Sanctum" },
  description: `The battered chest appears to be made of fire hardened teak or walnut bound with straps of dark, tarnished brass. `,
});

MyGame.createAsset({
  class: "Chalice",
  name: "glowing chalice",
  contains: "godsmead",
  place: { in: "Inner Sanctum" },
  description: `The chalice glows enticingly, continuously shifting color across the visible spectrum. You've never wanted anything so much in your life. `,
});

MyGame.createAsset({
  class: "Liquid",
  name: "godsmead",
  description: `The godsmead shimmers like liquid gold. `,
});

Further reference

  • You can use pronoun placeholders in descriptions.
    MyGame.createAsset({
      class: "Chest",
      name: "brass chest",
      description: `{We} see a small but sturdy looking chest bound in brass. `,
    });
    
    See placeholders for more info.
  • You can use placeholders in descriptions.
    MyGame.createAsset({
      class: "Door",
      name: "icy door",
      description: "The icy north door is { icy door [is] open [or] closed }."
    });
    See placeholders for more info.
  • You can use inline css in descriptions.
    MyGame.createAsset({
      class: "Chest",
      name: "golden chest",
      description: `It's a small wooden chest bound with straps of <span style="color:gold;">gold</span>. `,
    });
    See inline css for more info.
  • You can describe many different aspects of a single asset, including the feel, smell and taste, what can be seen through it, different descriptions depending on whether its open or closed, and more.
    MyGame.createAsset({
      class: "Candle",
      name: "glowing candle",
      descriptions: {
        look: `It's a thick, squat candle that seems to emit a golden glow even when unlit. `,
        smell: `The candle smells sweet, like beeswax, but with a mysterious hint of tang. `,
        listen: `The flame of the candle crackles gently in the breeze. `,
        taste: `Wax. Ugh. `,
      },
    });
    See advanced descriptions for more info.
  • You can apply modifiers to an asset's description, such as seeing an asset through a pair of glasses, or with a particular light source, or from a particular location, and more.
    MyGame.createAsset({
      class: "Paper",
      name: "middle earth map",
      descriptions: {
        look: {
          default: `It's a map of middle earth drawn on thick parchment. `,
          "with glowing candle": `The light of the glowing candle reveals a reflective spot on the map. `,
        },
      },
    });
    See advanced descriptions for more info.
  • You can set multiple different descriptions for an asset, so that a user sees something different each time they examine it.
    MyGame.createAsset({
      class: "Scenery",
      name: "air",
      description: {
        randomize: true,
        array: [
          `The air is hot and dry here. `,
          `Curiously, {we} smell a faint hint of cinnamon. `,
          `A sere wind wicks the sweat from your skin, though it offers no relief from the heat. `,
        ],
      },
    });
    See advanced descriptions for more info.
  • You can use custom functions in an asset's description.
    MyGame.createAsset({
      class: "Scenery",
      name: "sun",
      description: function () {
        if (MyGame.getVar("is_day") === true) {
          return `It burns overhead, baking everything in sight, including {us}. `;
        } else {
          return `Blessed night. The temperature has plummeted though. `;
        }
      },
    });
    See advanced descriptions for more info.