Lua Utility Functions

I wrote this function when I was trying to pprint some enormous tables full of subtables.

    --individually prints each line of a nested table
local function recursive_pprint(t, table_name)

    if not t then
        return
    end

    table_name = table_name or ""
    local type_table = "table"
    for key, value in pairs(t) do
        if type(value) == type_table then
            recursive_pprint(value, key)
        else
            print(table_name .. ": " .. key .. ": ", value)
        end
    end
4 Likes