Jump to content

Recommended Posts

I'm using the mod code (Universal Skins of Backpacks) to make a custom helmet use the same skins as Woodie's helmet (hardwood hat), however, when I apply any skin, the inventory image becomes invisible, even after switching to the default skin with the clean sweeper. I have no idea what the problem could be, could someone help me?
 

GLOBAL.setmetatable(env, {
    __index = function(t, k)
        return GLOBAL.rawget(GLOBAL, k)
    end,
})

GLOBAL.AddHatSkins = function(skins)
    local prefab_skins = {}
    for k, v in pairs(skins) do
        if PREFAB_SKINS[k] then
            for i, v in ipairs(PREFAB_SKINS[k]) do
                table.insert(prefab_skins, v)
            end
        end
    end

    for k, v in pairs(skins) do
        PREFAB_SKINS[k] = prefab_skins
        PREFAB_SKINS_IDS[k] = {}
        for i, v in ipairs(prefab_skins) do
            PREFAB_SKINS_IDS[k][v] = i
        end
    end

    if TheNet:GetIsClient() then
        return
    end

    for k, v in pairs(skins) do
        local init_fn = rawget(GLOBAL, k .. '_init_fn')
        if init_fn then
            GLOBAL[k .. '_init_fn'] = function(inst, build_name, ...)
                inst.AnimState:SetBank(v.bank)
                init_fn(inst, build_name, ...)
                basic_init_fn(inst, build_name, v.build)
            end
        end
    end

    for k, v in pairs(skins) do
        local clear_fn = rawget(GLOBAL, k .. '_clear_fn')
        if clear_fn then
            GLOBAL[k .. '_clear_fn'] = function(inst, ...)
                inst.AnimState:SetBank(skins[inst.prefab].bank)
                clear_fn(inst, ...)
                basic_clear_fn(inst, skins[inst.prefab].build)
            end
        end
    end

    for k, v in pairs(skins) do
        AddPrefabPostInit(k, function(inst)
            local onequip = inst.components.equippable.onequipfn
            inst.components.equippable.onequipfn = function(inst, owner)
                onequip(inst, owner)
                local skin_build = inst:GetSkinBuild()
                if skin_build then
                    owner.AnimState:OverrideItemSkinSymbol("swap_hat", skin_build, "swap_hat", inst.GUID, v.build)
                end
            end
        end)
    end
end

AddHatSkins({
    woodcarvedhat = {
        bank = "woodcarvedhat",
        build = "hat_woodcarved",
    },
    carvedhat = {
        bank = "woodcarvedhat",
        build = "hat_woodcarved",
    },
})


 

Link to comment
https://forums.kleientertainment.com/forums/topic/169617-invisible-inventoryimage/
Share on other sites

On 1/25/2026 at 9:35 AM, DarkM said:

I'm using the mod code (Universal Skins of Backpacks) to make a custom helmet use the same skins as Woodie's helmet (hardwood hat), however, when I apply any skin, the inventory image becomes invisible, even after switching to the default skin with the clean sweeper. I have no idea what the problem could be, could someone help me?
 

GLOBAL.setmetatable(env, {
    __index = function(t, k)
        return GLOBAL.rawget(GLOBAL, k)
    end,
})

GLOBAL.AddHatSkins = function(skins)
    local prefab_skins = {}
    for k, v in pairs(skins) do
        if PREFAB_SKINS[k] then
            for i, v in ipairs(PREFAB_SKINS[k]) do
                table.insert(prefab_skins, v)
            end
        end
    end

    for k, v in pairs(skins) do
        PREFAB_SKINS[k] = prefab_skins
        PREFAB_SKINS_IDS[k] = {}
        for i, v in ipairs(prefab_skins) do
            PREFAB_SKINS_IDS[k][v] = i
        end
    end

    if TheNet:GetIsClient() then
        return
    end

    for k, v in pairs(skins) do
        local init_fn = rawget(GLOBAL, k .. '_init_fn')
        if init_fn then
            GLOBAL[k .. '_init_fn'] = function(inst, build_name, ...)
                inst.AnimState:SetBank(v.bank)
                init_fn(inst, build_name, ...)
                basic_init_fn(inst, build_name, v.build)
            end
        end
    end

    for k, v in pairs(skins) do
        local clear_fn = rawget(GLOBAL, k .. '_clear_fn')
        if clear_fn then
            GLOBAL[k .. '_clear_fn'] = function(inst, ...)
                inst.AnimState:SetBank(skins[inst.prefab].bank)
                clear_fn(inst, ...)
                basic_clear_fn(inst, skins[inst.prefab].build)
            end
        end
    end

    for k, v in pairs(skins) do
        AddPrefabPostInit(k, function(inst)
            local onequip = inst.components.equippable.onequipfn
            inst.components.equippable.onequipfn = function(inst, owner)
                onequip(inst, owner)
                local skin_build = inst:GetSkinBuild()
                if skin_build then
                    owner.AnimState:OverrideItemSkinSymbol("swap_hat", skin_build, "swap_hat", inst.GUID, v.build)
                end
            end
        end)
    end
end

AddHatSkins({
    woodcarvedhat = {
        bank = "woodcarvedhat",
        build = "hat_woodcarved",
    },
    carvedhat = {
        bank = "woodcarvedhat",
        build = "hat_woodcarved",
    },
})


 

Try RegisterInventryItemAtlas; I think it will fix it.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...