Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

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

Code Block
themeEclipse
languagejavascript
linenumberstrue
function eventStartLevel() {
  // do stuff
}

Parameters

This event has no parameters.

Return value

Warzone does not process your event handler's return value.

Example

Code Block
themeRDark
languagejavascript
linenumberstrue
function startResearch() {
  // do stuff
}
 
function eventStartLevel() {
  setTimer("startResearch",1000); // make research start a second after the game starts
}
Div
classbox notice ping

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.

Div
classbox

Availability

Requires:

  • Warzone 3.1 Beta 1 and above.
Div
classbox

See also

Related articles: