chatwindow

This control defines the main chat window. The recommended location for it is in a desktop panel. Only one instance of the control can exist, attempts to create more than one will fail.

The chat window contains several chatentry objects representing the entries in the chat buffer. The messages added to the buffer can either be sent to other clients taking part in the session or used as local notification messages. See addMessage and deliverMessage for details.

See Comm package for details on the chat message structure.

When chat entries are dragged from the chat window, the type, text and total of the message will be used. If no type specified for the original chat entry, then the type will either be string or number, depending on whether a total is displayed on the chat entry.


Definition

<chatwindow name="..." > <modeframe > <mode > ... </mode> <name > ... </name> <offset > ... </offset> </modeframe> </chatwindow>

<chatwindow name="..." >

 

<modeframe >

 

<mode > ... </mode>

The mode that you want to assign a frame to.

<name > ... </name>

The bitmap frame resource name used for rendering the chat frame for this mode.

<offset > ... </offset>

A comma separated list of four numbers specifying the pixel margins applied to the chat frame when drawn

</modeframe>

 

</chatwindow>

 

Interface

addMessage

function addMessage(messagedata)

Add a new entry to the chat window history locally. The message is not delivered to other connected users, and the onReceiveMessage event is not fired.

Parameters

messagedata   (table)   
A table containing information about the message. See the Comm package for details.

clear

function clear()

Clear the chat history for all connected users. If called as a client, has no effect.

deliverMessage

Add a new entry to the chat window, delivering it to clients (if acting as the host) or requesting the host to distribute it to clients (if acting as a client).

Parameters

messagedata   (table)   
A table containing information about the message. See the Comm package for details.

recipients (string, or table of strings)

Optional. A string or table of strings containing the user name of the desired recipients. If missing, message will be broadcast to all connected clients.

throwDice

This function is used to trigger a roll of the dice without direct UI actions. Technically, the roll is performed by creating a dragdata object and triggering the action of the dice.

Parameters

dragtype   (string)   
The type used for the dragdata object. A value of "dice" performs a normal die roll.

dice   (table)   
An integer indexed list of die types to add to the roll, similar in function to dragdata.setDieList.

modifier   (number)   
The modifier applied to the roll (see dragdata.setNumberData).

description   (string)   
The description string applied to the roll (see dragdata.setDescription).

customdata   (any)   [optional]
A custom value useful for e.g. storing special information about the roll required when the results are displayed (see dragdata.setCustomData).

throwDice

An alternate version of the function used to trigger a roll of the dice without direct UI actions. Technically, the roll is performed by creating a dragdata object and triggering the action of the dice.

Parameters

data   (table)   
See the dragdata object for a description of the table (same as dragdata.setData)

Events

onDiceLanded

If present, this function is called whenever a die roll has been made and all dice have landed and had the result numbers assigned. For any custom dice, the custom value calculations have already been performed.

Parameters

draginfo   (dragdata)   
dragdata reference containing information about the drag used to roll the dice.

Return values

(boolean)
If true, the message is not processed any further, omitting it from the chat history.

onDiceTotal

If present, this function is called when a chat entry is added to the chat window.

Parameters

messagedata   (table)   
A table containing information about the message. See the Comm package for details.

Return values

(boolean)
Whether alternate total numeric value should be displayed, instead of the default total calculated by summing dice and modifier of chat entry.

(number)
alternate total numeric value for chat entry

onReceiveMessage

If present, this function is called whenever a message is delivered to the chat window (either by local or remote delivery), except those not propagated through delivery system (i.e. application system messages, or those added via the addChatMessage function.)

Parameters

messagedata   (table)   
A table containing information about the message. See the Comm package for details.

Return values

(boolean)
If true, the message is not processed any further, omitting it from the chat history.