1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-22 03:38:48 +02:00

Fix antigrief

This commit is contained in:
Gerkiz 2024-04-02 19:22:09 +02:00
parent 78530e468b
commit 70c64828bc
2 changed files with 25 additions and 3 deletions

View File

@ -714,7 +714,12 @@ local function on_console_command(event)
return
end
if not event.command == 'whisper' then
local valid_commands = {
['r'] = true,
['whisper'] = true
}
if not valid_commands[event.command] then
return
end
@ -730,14 +735,26 @@ local function on_console_command(event)
local parameters = event.parameters
local name, message = parameters:match('(%a+)%s(.*)')
if not message then
if not message and event.command == 'whisper' then
return
end
local chat_message
if event.command == 'r' then
chat_message = ' replied: "' .. parameters .. '"'
else
chat_message = ' whispered: "' .. name .. ' ' .. message .. '"'
end
if chat_message:len() == 0 then
return
end
local t = abs(floor((game.tick) / 60))
local formatted = FancyTime.short_fancy_time(t)
local str = '[' .. formatted .. '] '
str = str .. player.name .. ' whispered ' .. name .. ': ' .. message
str = str .. player.name .. chat_message
increment(this.whisper_history, str)
Server.log_antigrief_data('whisper', str)
end

View File

@ -104,6 +104,11 @@ local antigrief_tag = '[ANTIGRIEF-LOG]'
Public.raw_print = raw_print
local function output_data(primary, secondary)
local secs = server_time.secs
if secs == nil then
return false
end
if start_data and start_data.output then
local write = game.write_file
write(start_data.output, primary .. (secondary or '') .. newline, true, 0)