Removing from table in table

So I have a table wich looks like this

{
                    ["pasje1312"] =  ▼  { -- my username
                       ["Stage1"] =  ▼  {
                          ["1/16"] = true,
                          ["1/2"] = true,
                          ["1/32"] = true,
                          ["1/4"] = true,
                          ["1/8"] = true
                       }
                    }
                 }

I want to delete or make al the 1/… values false instead of true, but I dont know how. Could someone help me.

1 Like

For this, if you do not know the depth of your table, you could use a recursive function :

local function index_false(t)
    for i,v in t do
        if type(v) == "table" then
            index_false(v)
        elseif string.sub(i, 1,2) == "1/" then
            t[i] = false
        end
    end
end

Keep in mind that this function directly edits your table (instead of returning a changed one).
Hope this helps!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.