This AI is still in early stages of development.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Compiles a Babel format message, ready for sending to your AI buddies...

 

Syntax

var result = chat.toBabel(message[, dialect[, data[, replacer]]]);

Parameters

ParameterTypeMandatoryNotesAPI Version
messageString(tick)A basic message to send to the recipient, eg. "help"1.0
dialectString(error)

The dialect of your Babel message – this is usually an abbreviation of the name of your AI, or "ai" if using the Standard Dialect.

Default: "ai" (standard dialect)

1.0
dataVariant(error)

Optionally send data of any type with the message. Try and keep it small, it's being squeezed in to a chat message after all (wink)

Supported data types include: Any JS API Objects, including Game objects, or standard Javascript types such as Array, Object, String, Number, Boolean. You can also send null or undefined. Functions are automatically excluded from the compiled data.

Note: It helps if you specify Data types when sending custom objects.

(warning) Only enumerable "own" properties (and their values, recursively) will be sent.

Default: undefined

1.0
replacer

Function

Array

(error)

Optionally specify a JSON replacer function or array to filter out properties you don't want to send.

(warning) Will be ignored if data is a DROID, STRUCTURE, FEATURE, RESEARCH_DATA or PLAYER_DATA object (as internal replacers are used for those to minimise amount of data transmitted).

1.0

Return values

ValueTypeNotesAPI Version
<result>String

The message, dialect and data compiled in to a Babel-formatted string, ready for sending to a friendly AI via chat().

1.0
<error>

Error

Invalid parameters passed to function. Be sure to use Error Handling.1.0

Example

var message = chat.toBabel("defend", "ai", someStructureObj);
 
chat(someAIplayer, message);
Availability BETA

Requires:

Contents

Jump to:

Babel API

Topics:

 

  • No labels