Skip to content
This repository has been archived by the owner on Jul 19, 2018. It is now read-only.

ChatBox

Bomb Bloke edited this page Dec 22, 2015 · 1 revision
ChatBox
Type: chatbox
ID No.: 3471
Name: MoarPeripherals:blockChatBox

The ChatBox is a (turtle-equippable) peripheral block that can be used to interact with MineCraft's chat system. It offers functions to send messages, and fires events in response to messages received.

The ChatBox is capable of talking to all players, or PMing specific ones. It can detect regular chat messages, and can be "PM'd" by pre-fixing "##" to what you type - such messages do not appear in regular chat (barring third-party mod interference), but instead are only seen by ChatBoxes (with the leading hash symbols removed). The blocks can also detect information about player deaths.

When messaging, the names of ChatBoxes are enclosed within square brackets, as opposed to the chevrons wrapped around regular player names. ChatBoxes without names are presented as just "[ChatBox]".

The range of the ChatBox's sending and receiving abilities can be altered in moarperipherals.cfg. By default, they can "hear" from any range, transmit up to 64 blocks away (either publicly or via PM, though these can be configured individually), and send no more than a message per second. They can also optionally reveal their location in their messages (off by default).

This MoarPeripherals version of the ChatBox is similar to that seen in the MiscPeripherals mod (which is only compatible with older builds of ComputerCraft).

##Functions

Name Returns Description
say(string message) boolean success Sends a message to MineCraft chat. Any players in range of the ChatBox will receive it.
tell(string playerName, string message) boolean success Sends a private message to a specific player.
getLabel(string label) string label Returns the ChatBox's current label (blank by default).
setLabel(string label) {boolean success [, string error]} Changes the name that will appear next to messages posted by the ChatBox. Twenty characters maximum.
getReadRange() number range Players must be within range blocks for the ChatBox to hear them. Defaults to getMaxReadRange().
setReadRange(number range) boolean success Changes the listening range of the ChatBox. -1 means "unlimited".
getMaxReadRange() number range Returns the maximum listening range, per Moarperipherals.cfg. -1 means "unlimited", and is the default config setting.
getSayRange() number range Players must be within range blocks to hear regular messages from the ChatBox. Defaults to getMaxSayRange().
setSayRange(number range) boolean success Changes the regular messaging range of the ChatBox. -1 means "unlimited".
getMaxSayRange() number range Returns the maximum regular transmitting range, per Moarperipherals.cfg. 64 is the default.
getTellRange() number range Players must be within range blocks to hear private messages from the ChatBox. Defaults to getMaxTellRange().
setTellRange(number range) boolean success Changes the private messaging range of the ChatBox. -1 means "unlimited".
getMaxTellRange() number range Returns the maximum private transmitting range, per Moarperipherals.cfg. 64 is the default.

##Events

Type Parameter 1 Parameter 2 Parameter 3 Parameter 4
chat_message Peripheral "side". Player name. Message content.
death_message 1 Peripheral "side". Player name. Killer. Death type.
death_message (v1.3+) Peripheral "side". Player name. Death type. Killer.
chatbox_command 2 Peripheral "side". Player name. Message content.

1 For player deaths, mobs generate a "death type" of "mob". Presumably deaths caused by players trigger a type of "player" (unconfirmed). Environmental deaths (eg fall damage, lava) return nil for both "killer" ''and'' "death type".

2 Fired when a player prefixes a chat message with "##". Such messages will not appear in MineCraft chat (barring third-party mod interference), and are the equivalent of a PM to all operational chatboxes. The leading hash symbols are automatically removed from the received message.

##Recipe

Recipe

##Version History

Build Date Details
v1.5.0 15 December 2014 ChatBoxes can now be labelled and have their ranges individually specified (within the server's configured limits).
v1.3.0 8 October 2014 Fixed problem crash caused when short messages are sent.
''death_message'' event now supplies the cause of death.
v1.2.0 4 August 2014 ChatBoxes can now be equipped by Turtles.
More than one ChatBox can now get commands (sorry about that oversight).
New recipe.
v1.1.6 19 July 2014 Fixed chat bug in SMP.
v1.1.3 15 July 2014 Added new ChatBox event.
ChatBoxes now accept commands.
v0.2.1 24 June 2014 Initial release.