defineTextChat
defineTextChat<
Channels>(options?):TextChat<Channels>
Declares a game’s text chat: its channels and who receives a message.
Export it from src/game.ts and re-export it from the room’s scene file
beside the plugins, as export { plugins, room, textChat } from "../game". A game that exports none gets one all channel. The room
decides every message: its sender, her right to send, the channel, the
limits, the filter and each recipient; a game shapes who receives one,
never what it says. defineRoom({ textChat: false }) turns chat off.
As Roblox’s TextChatService, whose channels and delivery callback
these are.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Channels extends Record<string, TextChannel> |
object |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
TextChatOptions<Channels> |
Returns
Section titled “Returns”TextChat<Channels>
Example
Section titled “Example”export const textChat = defineTextChat({ channels: { all: textChannel(), team: teamTextChannel() }, // Ghosts receive everyone; the living never receive ghosts. shouldDeliver: (world, sender, recipient) => !isGhost(world, sender) || isGhost(world, recipient),});