Changes between Initial Version and Version 1 of Triggers


Ignore:
Timestamp:
Jun 22, 2014, 10:24:35 AM (10 years ago)
Author:
sanderd17
Comment:

First section about modifying the map file

Legend:

Unmodified
Added
Removed
Modified
  • Triggers

    v1 v1  
     1
     2= Triggers =
     3
     4This document will describe how to add triggers to maps, how to program triggers, and what the possibilities of triggers are.
     5
     6We 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 [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference 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 [http://www.notepad-plus-plus.org/ Notepad++] on Windows should be sufficient.
     7
     8== Modifying your map ==
     9
     10For 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 [source:ps/trunk/binaries/data/mods/public/maps/skirmishes/Alpine_Valleys_(2).xml#L42 example]). For random maps it's in the map.json file directly (see [source:ps/trunk/binaries/data/mods/public/maps/random/aegean_sea.json example]). (TODO: add link to committed triggers examples).
     11
     12In 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).
     13{{{
     14#!js
     15{
     16  "CircularMap": true,
     17  "Description": "The first steps of playing 0 A.D.",
     18  "...": "...",
     19  "TriggerScripts": [
     20    "scripts/TriggerHelper.js",
     21    "skirmishes/basic_tutorial.js"
     22  ]
     23}
     24}}}
     25
     26The 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.
     27
     28Of course, you need to make sure these files exist by creating them with your favourite text editor.
     29