-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not support newlines from anything printed (like love.errorhandler) #8
Comments
I have fixed the function myself, and opened a pull request #9 I changed the add_to_output from function add_to_output(...)
local arg = {...}
local narg = select("#", ...)
for i = 1, narg do
arg[i] = tostring(arg[i])
end
msg = parse.color(table.concat(arg, " "))
table.insert(output_buffer, msg)
end to function splitString(...)
local lines = {}
for _, str in ipairs({...}) do
for line in str:gmatch("[^\r\n]+") do
table.insert(lines, line)
end
end
return lines
end
function add_to_output(...)
for k, arg in ipairs(splitString(...)) do
msg = parse.color(table.concat({arg}, " "))
table.insert(output_buffer, msg)
end
end |
Updated to support some edge cases function splitString(...)
local lines = {}
for _, arg in ipairs({...}) do
if arg == nil then
-- Handle nil values
table.insert(lines, "<nil>")
elseif type(arg) ~= "string" and type(arg) ~= "boolean" then
-- Handle non-string and non-boolean values
table.insert(lines, tostring(arg))
else
local str = tostring(arg)
if type(arg) == "boolean" then
-- Convert boolean values to lowercase strings
str = str:lower()
end
for line in str:gmatch("[^\r\n]*\r?\n") do
-- Handle empty lines
if line ~= "\r\n" and line ~= "\n" then
table.insert(lines, line)
end
end
end
end
return lines
end |
You may actually want to check that, I'm not sure if that's completely correct |
Yea, that actually completely breaks everything, adjust the first one |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it just goes offscreen
The text was updated successfully, but these errors were encountered: