Other great resources: Official JS API docs, Scripting Forum
eventStartLevel()
- Aubergine
Â
Overview
This event is triggered once when a new game starts, it is not called when a saved game is loaded.
It is also triggered once after a new level has been loaded via loadLevel(). In this specific scenario, it is not recommended that timers be set in the eventStartLevel() event, as they may already be defined from when the event was previously called (exact scenario is ambiguous).
When the event is triggered, all player scripts have been initialised and Player Initialisation (base types, etc) has been applied.
- You can retrieve basic information about the game, such as playerData[] and use most if not all of the enum functions (such as enumDroid() and enumStruct())Â
- Do not issue any commands (such as production, research or droid orders), instead set timers to issue those commands at a later time.
- Any custom events (setTimer(), queue() or bind()) will not be triggered until after eventStartLevel() has finished processing.
It is considered best practice to use this event primarily for setting timers and queued function calls.
 It is recommended that you read Environment Sequences to gain a fuller understanding of this event in context of the initialisation sequence of a new game.
Syntax
function eventStartLevel() { // do stuff }
Parameters
This event has no parameters.
Return value
Warzone does not process your event handler's return value.
Example
function startResearch() { // do stuff } Â function eventStartLevel() { setTimer("startResearch",1000); // make research start a second after the game starts }
Availability
Requires:
- Warzone 3.1 Beta 1 and above.
See also
Related articles:
- Environment Sequences – recommended reading!
- eventGameInit() – triggered once at the start of a new game, prior to eventStartLevel() being triggered
- eventGameLoaded() – triggered when a saved game is loaded
- Events & Timers – documentation for all other events in the JS API
Â