Skip to main content

Chat

Many people have made lifelong friends through online games, thanks to being able to chat with the other players. It can be a wonderful thing, but it also can be a source of toxicity and harassment if not handled properly.

Enabling Chat​

By default, all multiplayer games have chat enabled, while singleplayer games do not. Simply using the maxHumanPlayers parameter will enable chat by default:

pub game fn World.Main(maxHumanPlayers=10) {
// chat is enabled for this game by default
}

Manually enabling chat​

The Chat function can be used to explicitly enable chat for your game, even if it is a singleplayer game:

pub game fn World.Main() {
Chat(show=true) // Enables chat for this singleplayer game
}

Manually disabling chat​

Use show=false to disable chat for your game, even if it is a multiplayer game:

pub game fn World.Main(maxHumanPlayers=10) {
Chat(show=false) // Disables chat for this multiplayer game
}

Chat rooms​

The Chat function can also be used to specify which players can chat with each other.

Chat with everyone in the game​

In a game with short matches, you may want to allow players to chat with all other players in the game, regardless of which match they are in:

Chat(interEpisode=true)
info

Chatting with everyone in the game is already the default behavior for multiplayer games, so you don't need to explicitly do this unless you have previously changed the chat settings.

Chat with just the players in your match​

In a game with long matches which require a lot of teamwork and collaboration, you may want to allow players to chat only with the players within their match.

Chat(interEpisode=false)

Chat with just your teammates​

In a competitive 5v5 game, you may even want to allow players to chat only with their teammates and not with their opponents. This stops teams from taunting each other, and focuses the chat on collaboration and strategising within the team. Here are a couple of ways you can do this:

Chat(interEpisode=false, room=$redTeam)
let teamNumber = 1
Chat(interEpisode=false, room=teamNumber)
info

The room parameter for Chat must be Sendable. That means it can only be a simple type like a number, string, or symbol. It cannot be a complex type like an Entity. So you cannot send your team Entity, but you can give your team a number or symbol and use that as the room.

Reply permissions​

Blocking one player from chatting​

Perhaps you are making a game where once players are dead, they cannot participate in the game anymore, and so should not be able to chat in order to avoid spoiling the game for the other players. Use the reply parameter of Chat to control whether players can send chat messages:

Chat(reply=false, audience=playerWhoIsDead)

Blocking spectators from chatting​

By default, spectators can chat too. If you have the kind of game where spectators might spoil the game, you might want to block spectators from chatting:

Chat(reply=false, audience=Audience:Spectators)

Customizing the reply key​

By default, players press Enter to send a chat message. Let's say you are making a typing speed test game, and you need to use the Enter key for submitting answers, but you still want players to be able to chat. You could remap the reply key to Tab instead:

Chat(reply=KeyTab)

Content filtering​

Easel automatically filters chat messages for inappropriate content. Don't forget you can ban players from your game if they are being disruptive or toxic. See Moderation to learn more.