diff --git a/res/layouts/ingame_chat.xml.lua b/res/layouts/ingame_chat.xml.lua index dce629887..fdd535045 100644 --- a/res/layouts/ingame_chat.xml.lua +++ b/res/layouts/ingame_chat.xml.lua @@ -19,7 +19,7 @@ local function update_line(line, uptime) end end -events.on("core:chat", function(message) +local core_chat_handler = events.on("core:chat", function(message) while #lines >= max_lines do document[lines[1][1]]:destruct() table.remove(lines, 1) @@ -36,7 +36,7 @@ end) function on_open() if not initialized then initialized = true - + document.root:setInterval(1/animation_fps * 1000, function () local uptime = time.uptime() for _, line in ipairs(lines) do @@ -52,3 +52,7 @@ function on_open() end) end end + +function on_destroy() + events.remove("core:chat", core_chat_handler) +end