Skip to content

Lua Utilities

Some useful functions for your scripts.

UniqueList

Make a list of table objects unique based a provided key.

function uniqueList(ls, key)
    local hash = {}
    local res = {}
    for _,v in ipairs(ls) do
        local test = v[key]
        if (not hash[test]) then
            res[#res+1] = v
            hash[test] = true
        end
    end
    return res
end