Added Statistics

This commit is contained in:
Cooldude2606
2020-05-30 01:45:02 +01:00
parent 4286e25803
commit 2dacbe9edd
6 changed files with 177 additions and 19 deletions

View File

@@ -11,11 +11,16 @@ local event_handlers = {}
-- map of nth_tick to handlers[]
local on_nth_tick_event_handlers = {}
local pcall = pcall
local trace = debug.traceback
local xpcall = xpcall
local log = log
local script_on_event = script.on_event
local script_on_nth_tick = script.on_nth_tick
local function handler_error(err)
log('\n\t'..trace(err))
end
local function call_handlers(handlers, event)
if _DEBUG then
for i = 1, #handlers do
@@ -24,11 +29,7 @@ local function call_handlers(handlers, event)
end
else
for i = 1, #handlers do
local handler = handlers[i]
local success, error = pcall(handler, event)
if not success then
log('\n\t'..error)
end
xpcall(handlers[i], handler_error, event)
end
end
end