(info) This AI is still in early stages of development.

Define API

An API for adding, removing or replacing properties on the global object / scope.

 

Overview

The primary purpose of the Define API is to alter the native Javascript API provided by Warzone 2100.

The JS API defines all it's constants, globals and functions as read-only, non-configurable properties on the global object. As such, they can only be altered by variables and constants in the global scope. Unfortunately, if you try defining a variable or constant in the global scope, and there is an immutable property of the same name on the global object, an error will be thrown – Javascript detects that you are doing something potentially stupid and steps in to block the action.

The Define API wraps some JS trickery in to a robust and reliable API which makes it trivially easy to work around these issues. Furthermore, you don't have to script your defines in the context of the global scope - you can put them in closures to keep them neatly packaged and avoid spamming the global object and scope with countless internal variables.

 

Availability BETA

Requires:

Define API

Topics:

  • Define() — Add, remove or redefine a property on the global scope, overriding any native property of the same name on the global object...
    • Define.has() — Check for presence of a global property...
    • Define.RESERVED — A reserved keyword (a native that cannot be changed)...
    • Define.stateOf() — Check state of a specific global property...
    • Define.hasNative() — Check for presence of a native global property...
    • Define.REMOVED — Indicates a native global was removed...
    • Define.MISSING — Indicates a global is not present (missing).
    • Define.NATIVE — Indicates a global was defined prior to including the Define API.
    • Define.REPLACED — Indicates a global was replaced by a script using the Define API.
    • Define.ADDED — Indicates a global was added by a script using the Define API.
  • Define API Diagnostics — Diagnostic routines for Define API...
  • Define Scripts — A library of ready made scripts for the Define API...

Â