From 39baa635afb7678accdd0e99dd6407467c9774fb Mon Sep 17 00:00:00 2001 From: yuppox <39724098+yuppox@users.noreply.github.com> Date: Sun, 31 Jul 2022 23:26:35 -0700 Subject: [PATCH] Update print_r.lua Fixed a bug. When the type of `val` == `table`, the original prints `tostring(t)` showing the wrong address. It should print `tostring(val)`. --- print_r.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/print_r.lua b/print_r.lua index 81ef325..0024fea 100644 --- a/print_r.lua +++ b/print_r.lua @@ -10,7 +10,7 @@ local function print_r ( t ) for i = 1, tLen do local val = t[i] if (type(val)=="table") then - print(indent.."#["..i.."] => "..tostring(t).." {") + print(indent.."#["..i.."] => "..tostring(val).." {") sub_print_r(val,indent..string.rep(" ",string.len(i)+8)) print(indent..string.rep(" ",string.len(i)+6).."}") elseif (type(val)=="string") then @@ -22,7 +22,7 @@ local function print_r ( t ) for pos,val in pairs(t) do if type(pos) ~= "number" or math.floor(pos) ~= pos or (pos < 1 or pos > tLen) then if (type(val)=="table") then - print(indent.."["..pos.."] => "..tostring(t).." {") + print(indent.."["..pos.."] => "..tostring(val).." {") sub_print_r(val,indent..string.rep(" ",string.len(pos)+8)) print(indent..string.rep(" ",string.len(pos)+6).."}") elseif (type(val)=="string") then