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

Working With...Area Zones

Area zones are containers for area scenery and area events that can be shared across rooms in the zone. For instance, you might create a desert zone with sandy wastes and dry air, or a dungeon zone with crumbling stone walls.

MyGame.createAsset({
    class: "Room",
    name: "Southern Dunes",
    zone: "Desert Zone"
  });  
    
  MyGame.createAsset({
    class: "Zone",
    name: "Desert Zone",

    area_scenery: {
      air: { enabled: true, description: "The air is searingly dry. " },
      sky: {
        enabled: true,
        description: "Even the sky is burnt to a pale sandy color. ",
      },
      sun: {
        enabled: true,
        description: "The sun burns in the sky. ",
      },
      floor: { enabled: true, description: "Nothing but endless sand. " },
      sound: { enabled: true, description: "A constant dry whisper of shifting sands. " },
    },

    area_events: {
      frequency: 0.1,
      randomize: true,
      array: [
        "Sands shift beneath your feet. ",
        "A brief dry breeze does nothing to cool you. ",
        "Heat haze shimmers over distant dunes. ",
      ],
    },
  });

  

String Array Function

Zone descriptions are subject to String Array Function which means that they can be set to return dynamic results. For instance, if you had a day/night cycle, you might set certain phenomena to appear differently during day and night.

MyGame.createAsset({
    class: "Zone",
    name: "Desert Zone",

    area_scenery: {
      sun: {
        enabled: true,
        description: function () {
          if( MyGame.getVar(is_night) ) { // using a world variable
            return `The sun lies somewhere below the horizon. `;
          }
          else {
            return `The sun bakes the desert floor. `;
          }
        },
      },
      moon: { 
        enabled: true, 
        description: function () {
          if( MyGame.getVar(is_night) ) {
            return `A big red desert moon illuminates the sands. `;
          }
          else {
            return `The moon is hidden beyond the horizon. `;
          }
        },
      },
      stars: {
        enabled: true,
        description: function () {
          if( MyGame.getVar(is_night) ) {
            return `Stars in their millions dot the coal blue night sky. `;
          }
          else {
            return `The stars are hidden by the blazing sun. `;
          }
        },
      },
    },
  

Further Reference