From fd545af9f2abd5e3c29cf1dc9faa44f5aa371506 Mon Sep 17 00:00:00 2001 From: luk3yx Date: Sat, 6 Feb 2021 21:31:39 +1300 Subject: [PATCH] Display multi-line messages in the console properly. --- console.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/console.lua b/console.lua index e70a6e2..6759852 100644 --- a/console.lua +++ b/console.lua @@ -112,10 +112,17 @@ function snippets.push_console_msg(name, msg, col) end local text = forms[name] and forms[name].context.text - if text then - table.insert(text, col .. tostring(msg)) - snippets.update_console(name) + if not text then return end + + msg = tostring(msg) + for _, line in ipairs(msg:split('\n', true)) do + text[#text + 1] = col .. line + if #text > 501 then + text[1] = '#aaaaaaSnippets only stores 500 lines of scrollback.' + table.remove(text, 2) + end end + snippets.update_console(name) end snippets.register_on_log(function(snippet, level, msg)