This AI is still in early stages of development.
Data types
- Aubergine
Primitive values
Babel supports all Javascript primitive values (string, number, boolean, null, undefined, etc).
JS API data types
Babel supports all JS API data types.
The following types will be sent verbosely (all properties are JSON stringified):
- AREA (Area object)
- POSITION (Position object) – see also: Position-like Objects.
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:
- PLAYER_DATA (Player object) – an .id (player ID) property is added to the object
- RESEARCH_DATA (Research object)
Note: Babel transparently deals with missing .type properties on Warzone 3.1 RC2 and earlier.
The following object types are not supported:
- GROUP (Group Object) – groups are private to your script. Support for lists of game objects is planned for a future release.
- <no type> (Weapon Object) – holding off supporting these until I'm sure their format is stable
- Labels – labels are private to a physical machine so transferring them between players is unreliable. Use getObject() to get the object associated with the label and send that object instead.
Custom objects and arrays
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().
.type properties
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.
Contents
Jump to:
Babel API
Topics:
- Data types — Babel supports most types of data...
- Error Dialect — A specific dialect for reporting errors within Babel...
- Babel on Warzone 3.1 — Babel handles Warzone 3.1 gracefully...
- Position-like Objects — If your data has {x, y} properties, Babel treats it like a Position object...
- chat.toBabel() — Compiles a Babel format message, ready for sending to your AI buddies...
- chat.isBabel() — Quickly determine if a received message is in Babel format...
- chat.fromBabel() — Converts a Babel format message in to an array...
- Handling Dialects — Some ideas on how to handle multiple dialects...