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

Script Environment

This section contains general information about the Javascript environment used by Warzone.

 

  • versionA string representing the game version being played.
  • Code sandboxingA brief tutorial showing how to sandbox a chunk of code, primarily to avoid it's variables leaking on to the global scope.
  • Environment SequencesDetails of the main environment sequences that occur in Warzone...
  • Javascript DebuggerThe JS debugger allows you to inspect scripts and labels...
  • include()Include library scripts in to your main script...
  • Common MistakesA summary of common issues you *will* run in to whilst developing against the JS API...
  • Error HandlingMost JS API functions and Javascript operations will "thow" an error if you use them incorrectly...
  • WZscript (.vlo and .slo) to Javascript (.js)This guide is designed to help developers who are converting their old WZScripts to the new Javascript API...
  • Timers
    • queue()Invoke a function at some point in the future...
    • setTimer()Allows you to trigger a function at some point in the future.
    • removeTimer()Allows you to cancel all queued and timed calls associated with a specific function...
  • Save / Load Cycle
    • Saved game filesHow do I work out what data is getting stored in save game files? Will it show me why my script is broken?
  • syncRandom()Generate a synchronised random integer...
  • Scopes & ClosuresThis article explains some important javascript concepts...
  • hackAssert()Assert a value and throw a game assert and JS error if it's falsey...
  • dump()Dumps text to a log file...
  • scriptNameThe filename of the main script loaded in to a particular scripting environment...
  • Native JS FeaturesA summary of the native Javascript features of the Warzone JS environment.
  • scriptPathThe path to the main script loaded in to a particular scripting environment...
  • debug()Outputs text to the terminal or log file depending on operating system.
  • IntroductionWarzone2100 contains a scripting language for implementing AIs, campaigns and some of the game rules...
  • Player ScriptsEach player in the game has a specific script associated with them...

Are there any processing time limits?

There's no hard time-liimt, like there is in a web browser. Instead, Warzone has "soft limits" that are used to detect problematic functions:

Warzone 3.1Warzone 3.2
50 ms20 ms

As of Warzone 3.2, a new performance log is appended to the dump() log after each game. It details which functions were invoked and how long they ran for. Ideally, all functions should take less than 5ms to process as this will minimise the chances of game lag when there are lots of scripts running (eg. in a 10 player game, there could be as many as 12 scripts running).