Skip to content

Chat Box

Picture

Header

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 the chat event fires.
Example:
$this message is hidden!

Overview

Peripheral Name Interfaces with Events Introduced in
chatBox Game Chat Yes 0.1b

Events

Event Name Parameter One Parameter Two Parameter Three Description
chat "chat" string username string message Fires when a player sends a message

Example

1
2
3
4
while true do
  event, username, message = os.pullEvent("chat") -- Will be fired when someone sends a chat message
  print(username.. " just wrote: ".. message) -- Prints "*User* just wrote: *Message*"
end

Info

The chat event will fire once a chatbox has been connected to the computer. You don't have to .wrap() or .find() the peripheral (unless you intend to send messages).

Functions

Function Returns Description
sendMessage(string message) Broadcasts a message to the global chat.
sendMessageToPlayer(string message, string username) Sends a message to one specific player.

Example

The Chat Box is quite easy to use. Wrap the peripheral and send messages or use the chat event.

1
2
3
4
5
6
local box = peripheral.find("chatBox") -- Finds a connected Chat Box

if box == nil then error("Missing Chat Box") end

box.sendMessage("Hey world") -- Sends a message to the global chat
box.sendMessageToPlayer("Hey you", "Player644") -- Send a message only to one specific player

Scripts & Examples

I made an script which emits a redstone signal if a player sends a specified message.

Script: here

Example Video: here

Changelog/Trivia

4.0b Fixed that the chat box is not working on LAN worlds

0.1b Added the chat box. It was the first feature of the mod.