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

Catalog heaven GUI adding?

Asked by 9 years ago

I want to add a new item to a catalog heaven catalog that i found. I added a doge but it shows up in the catalog as a question mark. How can i add it to make it blend in also updating the year old catalog? It gives unclear broad instructions in this code block: Also i want to add MULTIPLE items beside only doge sow how cn i do it?

-- ASSET SERVICE-----------------------------------------------------------

function GetNewAssetId()
    local newAssetId = 151784320, 162200696-- doge and yellow starface assets, but only can see doge.
    while _G.Assets[newAssetId] do
        newAssetId = newAssetId -151784320,162200696
    end
    return newAssetId
end


function LoadCatalog(assets)

    print(#assets:GetChildren())

    local childrenCount = assets:FindFirstChild("ChildrenCount")
    while childrenCount == nil do
        print("waiting for childrenCount")
        assets.ChildAdded:wait()
        childrenCount = assets:FindFirstChild("ChildrenCount")
    end

    while #assets:GetChildren() < childrenCount.Value do
        print("waiting for " .. childrenCount.Value .. " children")
        assets.ChildAdded:wait()
    end

    local concat = {}
    for _, child in pairs(assets:GetChildren()) do
        if child.ClassName == "StringValue" then
            concat[tonumber(child.Name)] = child.Value
        end
    end
    local total = table.concat(concat)

    local newIds = {151784320,162200696 }

    local newCatalog = loadstring("return " .. total)()
    if _G.Assets ~= nil then
        for id in pairs(newCatalog) do
            if _G.Assets[id] == nil then
                table.insert(newIds, id)
            end
        end
    end

    _G.Assets = newCatalog

    if #newIds > 0 then
        local localMessage = Instance.new("Message")
        localMessage.Text = "There are " .. #newIds .. " new items in the Catalog! Check em out!"
        game:GetService("Debris"):AddItem(localMessage, 15)
        localMessage.Parent = Workspace
        -- show a GUI showing new ones! :P
    end

    -- Building a lookup table that that is used for determining sorting of "random"
    math.randomseed(tick() + Workspace.DistributedGameTime)

    -- make a list of all assetIds
    local assetIds = {151784321,162200697 }
    for id in pairs(_G.Assets) do
        assetIds[#assetIds + 1] = id
    end

    -- create a lookup table for determing the sorting order of assetIds
    _G.Order = {}
    for i = 1, #assetIds do
        local randomIndex = math.random(#assetIds)
        _G.Order[assetIds[randomIndex]] =  i
        table.remove(assetIds, randomIndex)
    end

    _G.TimeStamp = game.Lighting.Timestamp.Value

end

-- can't use _G.Assets because it glitches in Solo Mode
if _G.Order == nil or game.Lighting.Timestamp.Value > _G.TimeStamp then
    LoadCatalog(game.Lighting.Assets)
end

game.Lighting.ChildAdded:connect(
function(child)
    if child.Name == "Assets" then
        local s, em= ypcall(LoadCatalog, child)
        if not s then
            local hint = Instance.new("Hint", Workspace)
            game:GetService("Debris"):AddItem(hint, 30)
            hint.Text = em
        end
    end
end)

Answer this question