This AI is still in early stages of development.
Command Mode
- Aubergine
Owned by Aubergine
Quick start guide for creating and using commands...
Overview
In this mode, Chat monitors all messages from the player to detect command keywords. When a keyword is found, the associated command handler function is triggered to process the message.
Step 1
Define your Command Handler Function:
var myCommand = function myCommand(command, player, message, conversation) { // command = command name (string) // player = id of player who sent the command (number) // message = array of words in chat message (message[0] == command) // conversation = conversation object associated with player // do some stuff // if you want a message sent to the player, // return a string or an array of strings return "done"; }
Step 2
chat.on("foo", myCommand);
Step 3
Triggering a command from a script using chat() with applicable Player Scope or player id:
chat(ALLIES, "foo"); // "done"
Triggering a command from the console:
Press Enter then type command
.foo
then press Enter to send.
Notes
Commands from a player will not be processed if there is an active Conversation with the player – during an active conversation all messages are sent to the Conversation Handler Function instead.
Looking for a list of available chat commands? See:
Contents
Jump to:
Chat API
Topics:
- Chat API Diagnostics — The Chat API provides the following diagnostic routines...
- Conversation Descriptor Object — Each player is assigned a Conversation Descriptor Object that defines the current state of their chat conversation...
- Conversation Mode — Quick start guide for making and using conversations...
- chat.isActive() — Determine conversation state for a specific player.
- chat.get() — Get the object associated with a multi-message conversation with a specific player.
- chat.stop() — Stop a conversation with a specific player.
- chat.extend() — Extend the "Time to Live" of the most recent conversation with a player.
- Conversation Handler Functions — How to define a conversation handler function....
- chat.start() — Start a multi-message conversation with a player.
- Command Mode — Quick start guide for creating and using commands...
- Command Handler Functions — How to define a command handler function....
- chat.on() — Define a chat command and it's handler function.