Babel supports most types of data... |
Babel supports all Javascript primitive values (string, number, boolean, null, undefined, etc).
Babel supports all JS API data types.
The following types will be sent verbosely (all properties are JSON stringified):
Game objects will be automatically minified to just their .type, .id and .player properties before being sent, and then regenerated by the receiving script:
Player and research objects are also minified before sending and then regenerated by the receiving script:
Note: Babel transparently deals with missing .type properties on Warzone 3.1 RC2 and earlier.
The following object types are not supported:
Babel supports custom objects and arrays as follows:
Included? | Notes |
---|---|
Enumerable own-properties and their values (including the contents of objects and arrays) are sent | |
Named properties on array objects are not sent (no way to represent them in JSON) | |
Functions are not sent, for obvious reasons | |
Prototype chain (__proto__ and prototype ) and associated properties are not sent |
Note: You can optionally filter out any unwanted properties using JSON "replacers" (arrays or functions) – for more info, see chat.toBabel().
Remember that JSON just sends a stringified representation of your object and it's properties – there's no way to specify an object class in JSON.
If you want to convey object types, use the same methodology as the JS API and provide a .type parameter, for example:
var myObj = { foo: "bar", type: "FUBAR" // this is the data type } |
If you can't think of a meaningful type, Babel has a ready made constant you can use:
var myObj = { foo: "bar", type: chat.CUSTOM_DATA } |
Note: If you're sending a Position-like Object, Babel automatically sets it's type to POSITION if there's no data type specified.
Providing a meaningful .type value enables recipients to process your data in a more consistent manner, but is not essential.