Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

Quick start guide for making and using conversations...

 

Step 1

Define a Conversation Handler Function:

Code Block
themeRDark
languagejavascript
linenumberstrue
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

Start a conversation:

Code Block
themeRDark
languagejavascript
firstline14
linenumberstrue
// example: conversation with player id 4
startConversationchat.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:

Code Block
themeRDark
languagejavascript
firstline18
linenumberstrue
extendConversationchat.extend(4); // give player 15 seconds to send their reply

Notes

If While there is an active Conversation with the player, commands will be ignored and all a player all chat messages from the that player will be sent to the conversation handler instead. 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.

Div
classbox

Availability
Status
colourYellow
titleBeta

Requires:

Div
classbox

Chat API

Topics:

Child pages (Children Display)
alltrue
depthall
pageChat API
excerpttrue