Other great resources: Official JS API docs, Scripting Forum
Native JS Features
- Aubergine
Native JS Environment Features
To find out what's in the JS environment, I used my tracebot AI script to prod and poke at various things.
Each of the headings below represents something I looked at (eg. Object = the JS Object class) followed by a bullet list of what I found. I've linked standard JS properties and methods to the related documentation on Mozilla Developer Network.
The properties are listed in the order returned by Object.getOwnPropertyNames(obj), not alphabetically.
global
The "global" object isn't defined in the WZ JS environment, but we can get at it by running this code on the global scope:
const global = this;
It contains:
- Math
- NaN
- undefined
- Infinity
- JSON
- Object (see below)
- Function (see below)
- Array (see below)
- Boolean
- String
- Number
- Date
- RegExp
- Error
- EvalError
- RangeError
- ReferenceError
- SyntaxError
- TypeError
- URIError
- eval()
- parseInt()
- parseFloat()
- isNaN()
- isFinite()
- escape()
- unescape()
- decodeURI()
- __proto__ == Object.prototype (see later)
So there's quite a bit missing compared to what you'd see in a browser.
You'll note that, unusually, escape and unescape are defined in the global object – in browsers those functions usually live on the "window" object, but because Warzone isn't a browser they've been moved.
Object
- name
- prototype == Object.prototype (see below)
- length
- getPrototypeOf()
- getOwnPropertyDescriptor()
- getOwnPropertyNames()
- keys()
- defineProperty()
- defineProperties()
- create()
- __proto__ == Object.prototype (see below)
Object.prototype
- toString()
- toLocaleString()
- valueOf()
- hasOwnProperty()
- propertyIsEnumerable()
- isPrototypeOf()
- __defineGetter__()
- __defineSetter__()
- __lookupGetter__()
- __lookupSetter__()
- constructor
Array
Array.__proto__
- length
- constructor
- join()
- reduceRight()
- toLocaleString()
- some() – see iHave(structure) for an example of using this
- push()
- forEach() – incredibly useful method for AI scripts! See orderGroupObj(group,dorder,obj) for an example of using this.
- map()
- splice()
- lastIndexOf()
- toString()
- sort()
- reduce()
- indexOf()
- slice()
- filter()
- concat()
- reverse()
- sort()
- pop()
- shift()
- every()
- unshift()
- __proto__ == Object.prototype (see above)
Function
This is the Function constructor on the global object.
- name
- prototype
- length
- prototype == Function.prototype (see later)
- __proto__ == Function.prototype (see later)
Function.prototype
- name
- length
- toString()
- apply()
- call()
- constructor
- disconnect
- connect
function
This is a function object (eg. one of your functions or event handlers), not the Function constructor (see above).
- arguments (see below)
- callee (non-standard? equivalent to arguments.callee)
- caller
- length
- name
- __proto__ == Function.prototype (see above)
arguments
String.prototype
The string prototype, and this all string object instances, has the following properties/methods:
- trimRight()
anchor()sup()blink()strike()- toLowerCase()
- match()
- valueOf()
- charCodeAt()
- trimLeft()
- lastIndexOf()
- trim()
sub()- search()
- toLocaleLowerCase()
- substring()
- toUpperCase()
link()bold()- split()
- concat()
- localeCompare()
- slice()
- indexOf()
- substr()
italics()- toString()
fontsize()small()- replace()
fontcolor()- chatAt()
big()- toLocaleUpperCase()
- length
Items that are striked out are HTML-only features that are not relevant to Warzone.
Contents
Assimilate: