1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-14 10:13:13 +02:00
RedMew/map_gen/shared/naughty_words.lua

28 lines
856 B
Lua
Raw Normal View History

2018-11-26 08:49:18 +02:00
local Game = require 'utils.game'
local Event = require 'utils.event'
global.naughty_words = require('resources.naughty_words')
local function admonish_blasphemy(event)
-- player_index is nil if the message came from the server,
-- and indexing Game.players with nil is apparently an error.
if not event.player_index then
return
end
local message = event.message:lower()
local player = Game.get_player_by_index(event.player_index)
if not player or not player.valid then
return
end
local naughty_words = global.naughty_words
for word in message:gmatch('%S+') do
if naughty_words[word] then
game.print(player.name .. ' this is a Christian Factorio server, no swearing please!')
break
end
end
end
Event.add(defines.events.on_console_chat, admonish_blasphemy)