The following pages detail examples of things you can do using map events, and the script interface within them.

Event Page Edit


The individual event pages are split up into the following parts:

Name Edit

Event names are mostly for your sake, the editor, so that you can keep track of what each event is for. Event names will ignore commas and semi-colons, since these characters are used as delimiters in the map file.

Condition Edit

Before you write what an event will actually be doing, you have to define when the event is going to be called, and this is done in the condition section. First of all, select a 'caller' from the list by clicking the button that is initially labelled "Never {". For now there are no explanations for any of the callers, but this feature is planned soon (we hope it is relatively self-explanatory for now).

Once you've selected a caller, some example code will be automatically inserted into the box under it. This code represents the condition, and will be evaluated each time the caller is triggered, until the condition returns true and the event's action is performed. The condition code must return true for the action to be called. Note that you can omit returning false, since this is assumed by default.

The condition code is editable and has complete access to the entire game engine. Alas, until our dwarves engine becomes open-source, you probably won't know how to utilise any of it. At the bottom of this page are some 'useful' details which may help you create the conditions you need.

Action Edit

Similar to the condition, the action code has complete access to the game engine. Once the action code is performed, the event is disabled and will longer be called. If you want the event to be called multiple times you can enter the code 'self.repeat();'. Both the condition and action code can reference any of the variables and call any of the functions inside Base.js.

Both the condition and the actoin can also call other scripts within the GameScripts folder by entering the code 'GameScript.runScript(<name>, self, [arg1, arg2, etc.]);'. Replace <name> with the name of the script (minus the extension), and [arg1, etc.] with whatever arguments you want to pass on. The game-script will then receive these arguments in the form args[0], args[1], etc.. Note, you will have to check the game-script to see what sort of arguments it's expecting. Game-scripts cannot return variables back to events, but they can call self.remember as a way of passing variables back.

Edit Vars Edit


This button opens the vars page which enables you to observe a few caller-related variables as well as create your own entity variables to refer to in the script. These variables will ignore commas, semi-colons and spaces. I recommend you also stick to alpha-numeric characters (a-z, 0-9), since you can then reference them directly in the scripts, e.g. in the picture you can write 'MyForager.addDecision(...'.

Note: there is another way to refer to variables, which is by using self.get(<name>), in which name can include non-alpha-numeric characters.

Examples Edit

Adding and maintaining Objectives

Dialog & Interjections

Debugging Scripts