From aac1635bf7ab09700136a7194e8827898edbe54f Mon Sep 17 00:00:00 2001 From: Jude Melton-Houghton Date: Tue, 29 Nov 2022 07:12:08 -0500 Subject: [PATCH] Have minetest.debug call tostring (#13004) --- builtin/init.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/builtin/init.lua b/builtin/init.lua index 869136016..96e7a937c 100644 --- a/builtin/init.lua +++ b/builtin/init.lua @@ -6,19 +6,22 @@ -- -- Initialize some very basic things -function core.debug(...) core.log(table.concat({...}, "\t")) end -if core.print then - local core_print = core.print - -- Override native print and use - -- terminal if that's turned on - function print(...) +do + local function concat_args(...) local n, t = select("#", ...), {...} for i = 1, n do t[i] = tostring(t[i]) end - core_print(table.concat(t, "\t")) + return table.concat(t, "\t") + end + function core.debug(...) core.log(concat_args(...)) end + if core.print then + local core_print = core.print + -- Override native print and use + -- terminal if that's turned on + function print(...) core_print(concat_args(...)) end + core.print = nil -- don't pollute our namespace end - core.print = nil -- don't pollute our namespace end math.randomseed(os.time()) minetest = core