Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Excerpt |
---|
Compiles a Babel format message, ready for sending to your AI buddies... |
Syntax
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
var resultbabelMessage = chat.toBabel(message[, dialect[, data[, replacer]]]); |
Parameters
Parameter | Type | Mandatory | Notes | API Version |
---|---|---|---|---|
message | String | A basic message to send to the recipient, eg. "help" | 1.0 | |
dialect | String | 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: | 1.0 | |
data | Variant | 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 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 Note: It helps if you specify Data types when sending custom objects. Only enumerable "own" properties (and their values, recursively) will be sent. For more information on what is supported, see Data types. Default: | 1.0 | |
replacer | Function Array | Optionally specify a JSON replacer array or function to change values or array to filter out properties you don't want to send. 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).unwanted properties. Default: Don't change or remove any properties. Not applied to the following data types as they use internal replacers:
| 1.0 |
Return values
Value | Type | Notes | API Version |
---|---|---|---|
<result><babelMessage> | 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
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
var messagebabelMessage = chat.toBabel("defend", "ai", someStructureObj); chat(someAIplayer, messagebabelMessage); |
Div | ||||||
---|---|---|---|---|---|---|
| ||||||
Availability
Requires:
|
Div | ||||
---|---|---|---|---|
| ||||
ContentsJump to:
|
Div | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
Babel APITopics:
|