This AI is still in early stages of development.
Conversation Mode
- Aubergine
Overview
In this mode, Chat sends all messages from the player to your conversation handler function. It's up to your handler function to decide what to do with the messages.
Conversations auto-expire after a set amount of time at which point the player goes back to Command Mode.
Step 1
Define a Conversation Handler Function:
var myConvHandler = function myConvHandler(command, player, message, conversation) { // command = first word in the message (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
// example: conversation with player id 4 chat.start(4, myConvHandler); chat(4, "What do you want me to do?");
By default, the user will be given 15 seconds to reply to a conversation before it expires.
Step 3
Remember to extend conversations after each interaction:
chat.extend(4); // give player 15 seconds to send their reply
Notes
While there is an active Conversation with a player all chat messages from that player will be sent to the conversation handler. This means they can't send Command Mode while a conversation is active.
Conversations will automatically expire if the player doesn't reply within a set amount of time (default: 15 seconds). You can stop a conversation at any time using chat.stop(). When a conversation ends, chat message handling will be returned to the command interface.
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.