SNIPPET : isInTableRecurse

Go down

SNIPPET : isInTableRecurse Empty SNIPPET : isInTableRecurse

Post by Regg on Fri 08 Mar 2013, 10:27

should be self-explanatory. returns an array of the index names in tableName containing entity. feel free to improve.

Code:
function isInTableRecurse(entity, tableName)
    if entity == nil or tableName == nil then
        return false;
    end
    local results = {}
    for i, v in pairs(tableName) do
        if type(v) == "string" and string.lower(entity) == string.lower(v) then
            table.insert(results, i)
        end
    end
    if #results > 0 then
        return results
    end
    return false
end
Regg
Regg
Veteran

Points : 143
Reputation : 10
Join date : 2013-02-22

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum