Other great resources: Official JS API docs, Scripting Forum
Script Environment
- Aubergine
Owned by Aubergine
This section contains general information about the Javascript environment used by Warzone.
- version — A string representing the game version being played.
- Code sandboxing — A brief tutorial showing how to sandbox a chunk of code, primarily to avoid it's variables leaking on to the global scope.
- Environment Sequences — Details of the main environment sequences that occur in Warzone...
- Javascript Debugger — The JS debugger allows you to inspect scripts and labels...
- include() — Include library scripts in to your main script...
- Common Mistakes — A summary of common issues you *will* run in to whilst developing against the JS API...
- Error Handling — Most 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 files — How 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 & Closures — This 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...
- scriptName — The filename of the main script loaded in to a particular scripting environment...
- Native JS Features — A summary of the native Javascript features of the Warzone JS environment.
- scriptPath — The 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.
- Introduction — Warzone2100 contains a scripting language for implementing AIs, campaigns and some of the game rules...
- Player Scripts — Each 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.1 | Warzone 3.2 |
---|---|
50 ms | 20 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).