Version 1.8

This commit is contained in:
OTCv8
2020-01-10 02:29:15 +01:00
parent 2a10e65ec0
commit 26c347d2bc
38 changed files with 531 additions and 792 deletions

View File

@@ -8,12 +8,24 @@ context.callback = function(callbackType, callback)
if callbackType == "onAddThing" or callbackType == "onRemoveThing" then
g_game.enableTileThingLuaCallback(true)
end
local desc = "lua"
local info = debug.getinfo(2, "Sl")
if info then
desc = info.short_src .. ":" .. info.currentline
end
local callbackData = {}
table.insert(context._callbacks[callbackType], function(...)
if not callbackData.delay or callbackData.delay < context.now then
local prevExecution = context._currentExecution
context._currentExecution = callbackData
local start = g_clock.realMillis()
callback(...)
local executionTime = g_clock.realMillis() - start
if executionTime > 100 then
context.warning("Slow " .. callbackType .. " (" .. executionTime .. "ms): " .. desc)
end
context._currentExecution = prevExecution
end
end)