Chat Box¶
The Chat Box is able to read and write messages to the in-game chat. You can send messages to just one player or to everyone.
Hint
If you prefix your message with a $ the message will not be sent to the global chat but it will still fire the chat event.
Example:
$this message is hidden!
| Peripheral Name | Interfaces with | Has events | Introduced in |
|---|---|---|---|
| chat_box | Game Chat | Yes | 0.1b |
Events¶
chat¶
Fires when a chat message appears within a chatbox's detection range.
Values:
uuid: stringMessage sender's UUID.nilif triggered from a /say commandname: stringMessage sender's name.[say]if triggered from a /say commandmessage: stringThe chat messageisHidden: booleanWhether or not the message is privately sent to chatboxesencodedUtf8Message: stringThe encoded chat message from utf8
1 2 | |
Info
The chat event will fire when a chatbox has been connected to a computer. You don't have to .wrap() or .find() the peripheral (unless you intend to send messages).
Functions¶
sendMessage¶
sendMessage(message: string, options: table | nil) -> true | nil, string
Broadcasts a message to the global chat or if range is specified it is sent to all players in the range.
Returns true if the message is successfully sent, or nil and an error message if it fails.
options format:
{
player: string | nil = message will only send to the player when specified
utf8: boolean | nil = if strings and message should be treated as encoded utf8
range: number | nil = the broadcast range
prefix: string | nil = change the text that appears inside the brackets at the start of a message. Defaults to "AP".
brackets: string | nil = used around the prefix. Must specify a two length string like "[]", "()", "<>", ...
bracketColor: string | nil = specifies the color to use for the brackets, must be in the [MOTD code format](https://www.digminecraft.com/lists/color_list_pc.php).
}
Returns true if the message is successfully sent, or nil and an error message if it fails.
1 2 3 4 5 6 7 8 9 10 11 12 | |
Tip
Just like the bracketColor argument you can add colors to the message and prefix arguments using the same MOTD color code format.
Since CC doesn't accept non-ascii charactor ยง, you should replace it with &.
If you want to send colored message but not only colored brackets, please use sendFormattedMessage() instead.
sendFormattedMessage¶
sendFormattedMessage(json: string, options: table | nil) -> true | nil, string
sendMessage() except it takes a json text component as the first parameter.Find out more information on how the text component format works on the minecraft wiki. You can generate the json at minecraft.tools.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
sendToast¶
sendToast(options: table) -> true | nil, string
options format:
{
message: string = the message in the toast
title: string = the title of the toast
player: string = player's name or uuid
utf8: boolean | nil = if strings should be treated as encoded utf8
prefix: string | nil = change the text that appears inside the brackets at the start of a message. Defaults to "AP".
brackets: string | nil = used around the prefix
bracketColor: string | nil = specifies the color to use for the brackets
}
1 2 3 4 5 6 7 8 9 10 | |
sendFormattedToast¶
sendFormattedToast(options: table) -> true | nil, string
sendToast() except it takes a json text component for message, and title fields.Find out more information on how the text component format works on the minecraft wiki. You can generate the json at minecraft.tools.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
narrateMessage¶
narrateMessage(message: string, options: table | nil) -> true | nil, string
Narrate the message to players around.
Warning
Narration is based on individual player's system settings. People may hear different sounds and/or different speech speeds. The same word may also be pronounced differently, or may not be pronounced at all, depending on their system language.
options format:
{
player: string | nil = message will only send to the player when specified
utf8: boolean | nil = if strings should be treated as encoded utf8
delay: boolean | nil = if the narrate message should queued after the previous narrations
}
1 2 3 4 5 6 | |
Changelog/Trivia¶
0.8
Added narrateMessage.
Merged sendMessageToPlayer variant to sendMessage by specific player option value.
1.19.2-0.7.33r/1.20.1-0.7.37r
Added sendToastToPlayer and sendFormattedToastToPlayer
0.7r
Added the uuid and isHidden parameter to the chat event. Also added the sendFormattedMessage function.
4.0b
Fixed the chat box so that is should now work in LAN worlds
0.1b
Added the chat box. This was the first feature of the mod.

