(info) Other great resources: Official JS API docs, Scripting Forum

eventStartLevel()

This event is triggered once at the start of a new game after the map is ready and all game data loaded. It is also triggered once after a new level is loaded.

 

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.

(warning) 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
}
You can't trigger research from within this event. Instead, use queue() or setTimer() to trigger a function at some later time to start the research.

Availability

Requires:

  • Warzone 3.1 Beta 1 and above.

See also

Related articles: