1. function print_r ( t )
    2. local print_r_cache={}
    3. local function sub_print_r(t,indent)
    4. if (print_r_cache[tostring(t)]) then
    5. print(indent.."*"..tostring(t))
    6. else
    7. print_r_cache[tostring(t)]=true
    8. if (type(t)=="table") then
    9. for pos,val in pairs(t) do
    10. if (type(val)=="table") then
    11. print(indent.."["..pos.."] => "..tostring(t).." {")
    12. sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
    13. print(indent..string.rep(" ",string.len(pos)+6).."}")
    14. elseif (type(val)=="string") then
    15. print(indent.."["..pos..'] => "'..val..'"')
    16. else
    17. print(indent.."["..pos.."] => "..tostring(val))
    18. end
    19. end
    20. else
    21. print(indent..tostring(t))
    22. end
    23. end
    24. end
    25. if (type(t)=="table") then
    26. print(tostring(t).." {")
    27. sub_print_r(t," ")
    28. print("}")
    29. else
    30. sub_print_r(t," ")
    31. end
    32. print()
    33. end