Code: Select all
if log_level >= 2 then printmsg("test", false) end
local lastMessages = {}
function printmsg(msg, useFilter)
if useFilter == nil then
useFilter = true
end
--suppress message if among the last n messages
if useFilter and message_filter_size > 0 then
for i=#lastMessages, 1, -1 do
if lastMessages[i] == msg then --don't spam the same message
return
end
end
lastMessages[#lastMessages+1] = msg
if #lastMessages > message_filter_size then --remove oldest message
table.remove(lastMessages, 1)
end
end
if log_output == "console" or log_output == "both" then
game.print("[LTN] " .. msg)
end
if log_output == "log" or log_output == "both" then
log("[LTN] " .. msg)
end
end
Is there a way to make this work per player or do i have to turn log_level, log_output and lastMessages into globals so they are synced?