Global chat by default for multiplayer?

Place to get help with not working mods / modding interface.
User avatar
Dummiez
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Mar 28, 2020 4:00 am
Contact:

Global chat by default for multiplayer?

Post by Dummiez »

I'm in the process of setting up a server for some friends where they have their own individual research by creating their own force when they join. However, due to the default chat only displaying to other players within the same force it's quite a bother to have to type '/shout' every time just to be able to talk to other players in the game. Is it possible to make it so that all players can see the chat without prefixing or the use of additional chat bars? Thanks in advance.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Global chat by default for multiplayer?

Post by DaveMcW »

Code: Select all

script.on_event(defines.events.on_console_chat, function(event)
    local author = game.get_player(event.player_index)
    for _, player in pairs(game.players) do
        if player.force ~= author.force then
            player.print(author.name .. ": " .. event.message, author.color)
        end  
    end
end)
User avatar
Dummiez
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Mar 28, 2020 4:00 am
Contact:

Re: Global chat by default for multiplayer?

Post by Dummiez »

Ah thanks, didn't realize that you could print to individual players.
Post Reply

Return to “Modding help”