Allow mods/scenarios to filter chat messages

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
cliff_build
Inserter
Inserter
Posts: 20
Joined: Thu Dec 03, 2020 4:52 pm
Contact:

Allow mods/scenarios to filter chat messages

Post by cliff_build »

This is a general request of "allow mods to control/augment/filter chat messages" - and a possible proposal to do it via something like "game.do_not_print_broadcasted_chat_messages = true". This would then allow a scenario/mod to register an on_console_chat event handler, and manually do the player.print() augmented message.

A different possible way to implement this would be to have a on_deliver_chat_message event, which has a default handler that essentially calls player.print, and some option to remove the default handler.

Ideally the functionality would also cover /shout, /whisper, and /reply (i.e. some way of preventing them from being printed, and we could use on_console_command to implement the functionality ourselves), but those are less important to me (it would also be fine if the same overall option just prevented whisper and shout as well).

Also, Ideally, there would be a form of player.print that we could pass a "from_player" argument, so that /ignore would continue to work as expected.

This request is related to the on_pre_console_chat request: viewtopic.php?f=28&t=53976 But the suggested implementation is different enough that I thought that it deserved its own post. If forum admins feel differently, feel free to close this request.

For context as to why I want this functionality: in Biter Battles, we have three relevant forces, "north", "south", and "spectator". It is very helpful if we can augment messages to indicate who can see them. We already have "/north-chat", "/south-chat" and "/spectator-chat" commands, but it is annoying to use them every time, and many new players do not know/understand who can see their chats when they just send them normally (especially because the rules for spectators are confusing, depending on whether it is a "tournament mode" game or not). Thus it would be nice if we could always print out something like "(spectator) username (to all): message" vs "(to north)" etc.
Post Reply

Return to “Modding interface requests”