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

Data types

Babel supports most types of data...

 

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):

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:

  • (error) GROUP (Group Object) – groups are private to your script. Support for lists of game objects is planned for a future release.
  • (error) <no type> (Weapon Object) – holding off supporting these until I'm sure their format is stable
  • (error) 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
(tick)Enumerable own-properties and their values (including the contents of objects and arrays) are sent
(error)Named properties on array objects are not sent (no way to represent them in JSON)
(error)Functions are not sent, for obvious reasons
(error)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.

Availability BETA

Requires:

Contents

Jump to:

Babel API

Topics: