Functions
The chat of client-side scripts: local messages, showing and hiding the chat, the time before the lines.
How players' messages look is decided by the server: its onPlayerChat handler can replace their lines (eventValue), sendMessage writes to one player.
Chat
The chat is in the top left corner of the screen. Messages disappear 12 seconds after they came; the player opens the input line with T (all recent messages are shown again while typing), sends with Enter and cancels with Esc. Up/Down bring back the messages the player sent, PageUp/PageDown scroll older ones. What players write goes to the server; its onPlayerChat handler can change how their lines look (eventValue).
addChatMessage
addChatMessage(color, text)Shows a line in the local chat window (only for this player; to send to everyone use the server's
sendMessageToAll). The line has the given color (without it - only the text - the line is white);
inside the text {RRGGBB} switches the color of the rest of the line (until the next code). Only
exactly { + 6 hex digits + } is a color code.
addChatMessage(0xC9A368, "Lorem ipsum dolor sit amet.")
addChatMessage("{FF8080}Lorem{FFFFFF} ipsum {80FF80}dolor{FFFFFF} sit amet.")| Parameter | Type | Description |
|---|---|---|
color | integer | Color of the line as 0xRRGGBB. |
text | string | Text (UTF-8), optionally with {RRGGBB} color codes. |
showChat
showChat(show)Shows or hides the whole chat - e.g. during a login screen or a cutscene of the server. A hidden chat still collects the messages (shown together with it again, if they have not disappeared by then) and T does not open it; hiding it while the player types closes the input line.
showChat(false) -- e.g. when the login window opens
showChat(true) -- after logging in| Parameter | Type | Description |
|---|---|---|
show | boolean | true = show the chat, false = hide it. Shown by default. |
Returns: boolean - Always true.
isChatShown
isChatShown()Whether the chat is shown (see showChat).
Returns: boolean
showChatTime
showChatTime(show)Shows or hides the time before every chat line - [14:05] Lorem ipsum. It is the player's local time at
which the line came; it applies to the lines already in the chat too.
showChatTime(true)| Parameter | Type | Description |
|---|---|---|
show | boolean | true = show the time, false = hide it. Hidden by default. |
Returns: boolean - Always true.
isChatTimeShown
isChatTimeShown()Whether the chat shows the time before the lines (see showChatTime).
Returns: boolean
