Quellcode durchsuchen

Have minetest.debug call tostring (#13004)

Jude Melton-Houghton vor 1 Jahr
Ursprung
Commit
aac1635bf7
1 geänderte Dateien mit 11 neuen und 8 gelöschten Zeilen
  1. 11 8
      builtin/init.lua

+ 11 - 8
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