Version 1 (modified by sanderd17, 10 years ago) ( diff )

First section about modifying the map file

Triggers

This document will describe how to add triggers to maps, how to program triggers, and what the possibilities of triggers are.

We will try to give a lot of examples, that should be easy to copy-paste and modify where needed. But this isn't meant as an introductory course to JavaScript. For a JavaScript reference, it's best to look at the Mozilla Development Network (MDN). For creating and editing JavaScript files, it's best to use a decent text editor. Syntax highlighting is a must, so Notepad++ on Windows should be sufficient.

Modifying your map

For now, Atlas isn't very prepared for triggers. So we have no GUI to edit triggers (obviously), but also no GUI to add trigger scripts to your map. This means you need to edit your map data. For scenarios and skirmish maps, this map data is a JSON part in the map.xml file (see example). For random maps it's in the map.json file directly (see example). (TODO: add link to committed triggers examples).

In this JSON part of the data, you define an array of loaded trigger scripts. You can define multiple more general helper scripts, and your custom script(s).

{
  "CircularMap": true,
  "Description": "The first steps of playing 0 A.D.",
  "...": "...",
  "TriggerScripts": [
    "scripts/TriggerHelper.js",
    "skirmishes/basic_tutorial.js"
  ]
}

The root of these paths is in modName/maps/, and it's custom to put general scripts in the scripts directory, and map-specific scripts next to the existing map files.

Of course, you need to make sure these files exist by creating them with your favourite text editor.

Note: See TracWiki for help on using the wiki.