Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PrintTable( Table )
- local Cache = { }
- local function SubPrintTable( Table, Level )
- local Indent1 = ( " " ):rep( Level * 4 )
- local Indent2 = ( " " ):rep( ( Level - 1 ) * 4 )
- if ( Cache[ tostring( Table ) ] ) then
- print( Indent1 .. "*" .. tostring( Table ) )
- else
- Cache[ tostring( Table ) ] = true
- if ( type( Table ) == "table" ) then
- for Key, Value in pairs( Table ) do
- Key = tostring( Key )
- if ( type( Value ) == "table" ) then
- print( ( "%s[ %q ] = {" ):format( Indent1, Key ) )
- SubPrintTable( Value, Level + 1 )
- print( Indent2 .. ( " " ):rep( 4 ) .. "}" )
- elseif ( type( Value ) == "string" ) then
- print( ( "%s[ %q ] = %q," ):format( Indent1, Key, Value ) )
- else
- print( ( "%s[ %q ] = %s," ):format( Indent1, Key, tostring( Value ) ) )
- end
- end
- else
- print( Indent1 )
- end
- end
- end
- if ( type( Table ) == "table" ) then
- print( tostring( Table ) .. " = {" )
- SubPrintTable( Table, 1 )
- print( "}" )
- else
- SubPrintTable( Table, 1 )
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement