Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I want create inventory save. How to make normal converter to table?

Asked by
Shaehl -11
5 years ago

My script:

function MakeSomethingNext(obj,funct)
    for _, subobj in pairs(obj:GetChildren()) do
        funct(subobj)
        MakeSomethingNext(subobj,funct)
    end
end

function YourInventoryTable(inv)
    local Table = {}
    local parent
    MakeSomethingNext(inv,function(obj)
        local typ
        if #obj:GetChildren() > 0 then
            typ = "Store"
            Table[obj.Name] = {}
            parent = obj.Name
        else
            if obj:IsA("ValueBase") then
                local link = Table[obj.Name] -- Don't work.
                if parent then
                    link = Table[parent][obj.Name] -- Hov to fix it?
                end
                typ = "Value"
                link = obj.Value -- Is there another way to create this?
            end
        end
    end)
    return Table
end

But i don't know how to make importing to subtables. How to make it? Help! It doesn't work! I'm confused.

0
I think the reason for this is that the variable link is a value that is equivalent to Table[obj.Name], it doesn't actually represent that slot of th table theking48989987 2147 — 5y
0
Try to use for i,v in pairs() I'm doing this when manipulate table Diltz_3 75 — 5y

Answer this question