Pre-release
AdventureJS Docs Downloads Bundler Devlog Score: 0 Moves: 0
Tutorial explaining how to work with area scenery in AdventureJS. tutorial, area scenery, global assets

Working With...Area Scenery

Area scenery are simple objects that only exist to provide a description of non-interactable scenery, like the sun, or stars, or a distant mountain range. Scenery objects can be singular (in one room) or global (in multiple rooms). Here is all it takes to make a scenery object that only exists in one place.

MyGame.createAsset({
    class: "Room",
    name: "Wooded Glen",
    area_scenery: {
      fireflies: {
        description: "Blinking fireflies dot the evening air.",
      },
    },
  

Making Scenery Global

Scenery objects can appear in multiple rooms with different descriptions. To make a global scenery object, we need to add a couple more properties. In this example, we create a scenery object and specify it as origin and global.

MyGame.createAsset({
  class: "Room",
  name: "Wooded Glen",
  area_scenery: {
    fireflies: {
      description: "Fireflies dot the forest with fairy lights.",
      origin: true, // specify that this is the origin
      is: { global: true }, // specify that it's global
    },
  },
});

MyGame.createAsset({
  class: "Room",
  name: "Stony Field",
  area_scenery: {
    fireflies: {
      // give this room its own description for this object
      description: "Fireflies hover above the stony field.",
    },
  },    
});
  

Built-in Global Scenery

AdventureJS has several dozen built-in scenery objects that can be configured by room, by zone, or for the entire game. Game settings are overridden by zone settings, and zone settings are overridden by room settings, so it's possible to set generic descriptions for all of these objects and then customize them for specific zones or rooms.

Built-in scenery falls loosely into three categories.


SCENERY PHENOMENA

Generic scenery covers basic atmospheric phenomena like the sun and the sky and distant mountains.

SCENERY WALLS

Scenery walls can help respond to player input like examine east wall. If a room actually has an east wall, you can describe it; if it doesn't, you can offer a non-response.

Floor and ceiling are similar to walls but slightly different. If you add a real floor or ceiling to a room, it will automatically override the scenery floor/ceiling.

SCENERY EXITS

Scenery exits can help respond to players trying to examine non-existent exits. These are subject to String Array Function, so you could do something like have a non-existent exit return a list of all viable exits for the current room.

Here's how you would apply a built-in global scenery object to a room.

MyGame.createAsset({
  class: "Room",
  name: "Wooded Glen",
  area_scenery: {
    sun: {
      enabled: true,
      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. `;
        }
      },
    },
  },
});
  

Our sun example can also be applied to a zone instead of a room, making the sun available to all rooms in the zone. This might be helpful for creating below-ground / above-ground zones.

MyGame.createAsset({
  class: "Room",
  name: "Wooded Glen",
  zone: "Woody Zone",
)};
MyGame.createAsset({
  class: "zone",
  name: "Woody Zone",
  area_scenery: {
    sun: {
      enabled: true,
      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. `;
        }
      },
    },
  },
});

Game-Wide Scenery

Finally, it is possible to apply the built-in scenery to the entire game world. This uses a different mechanism: the game.setAreaScenery() method.

MyGame.setAreaScenery({
  sun: {
    enabled: true,
    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. `;
      }
    },
  },      

Remember: local effects always override global effects, meaning that room takes precedence over zone, and zone takes precedence over game. You can enable a scenery object for the entire game, then customize it for a zone, then customize it further for a specific room.

Further Reference