Jump to content

Recommended Posts

Ive created a hat-type item and everything appears to work except -

when the item is equipped, it becomes invisible.

 

It appears in the character's inventory fine, and in the build menu of the science engine.

 

The log file doesn't seem to show any reason for this error.

 

withing the modmain.lua

Assets = {

 

    Asset( "IMAGE", "images/inventoryimages/logicfilter.tex" ),
    Asset( "ATLAS", "images/inventoryimages/logicfilter.xml" ),
 
}

  

within the Item's Lua file

local assets=
    {
        Asset("ANIM", "anim/logicfilter.zip"),
        Asset("ATLAS", "images/inventoryimages/logicfilter.xml"),
    }

 

local function onequip(inst, owner)
        owner.AnimState:OverrideSymbol("swap_hat", "logicfilter", "swap_hat")
        owner.AnimState:Show("HAT")
        owner.AnimState:Hide("HAT_HAIR")
        owner.AnimState:Show("HAIR_NOHAT")
        owner.AnimState:Show("HAIR")
        
        owner.AnimState:Show("HEAD")
        owner.AnimState:Hide("HEAD_HAIR")
                
end

 

 local function fn(Sim)
        local inst = CreateEntity()
        local trans = inst.entity:AddTransform()
        local anim = inst.entity:AddAnimState()
        MakeInventoryPhysics(inst)
        
        inst:AddTag("hat")
        
        inst.AnimState:SetBank("footballhat")
        inst.AnimState:SetBuild("logicfilter")
        inst.AnimState:PlayAnimation("anim")
        inst:AddComponent("inspectable")

        inst:AddComponent("equippable")
        inst.components.equippable.equipslot = EQUIPSLOTS.HEAD
    
        inst:AddComponent("inventoryitem")
        inst.components.inventoryitem.atlasname = "images/inventoryimages/logicfilter.xml"
    
        return inst
    end

 

I'm certain I am missing something obvious....

but I have no idea what.

 

I checked the atlas-0.tex, in the logicfilter.zip file and it is good, as best I can tell.

and I used an editor to change the build.bin to the proper name.

I left the anim.bin alone (leaving the default footballhat)

Edited by MidrealmDM
Link to comment
https://forums.kleientertainment.com/forums/topic/35274-invisible-hat/
Share on other sites

Ive created a hat-type item and everything appears to work except -

when the item is equipped, it becomes invisible.

 

It appears in the character's inventory fine, and in the build menu of the science engine.

 

The log file doesn't seem to show any reason for this error.

 

withing the modmain.lua

Assets = {

 

    Asset( "IMAGE", "images/inventoryimages/logicfilter.tex" ),

    Asset( "ATLAS", "images/inventoryimages/logicfilter.xml" ),

 

}

  

within the Item's Lua file

local assets=

    {

        Asset("ANIM", "anim/logicfilter.zip"),

        Asset("ATLAS", "images/inventoryimages/logicfilter.xml"),

    }

 

local function onequip(inst, owner)

        owner.AnimState:OverrideSymbol("swap_hat", "logicfilter", "swap_hat")

        owner.AnimState:Show("HAT")

        owner.AnimState:Hide("HAT_HAIR")

        owner.AnimState:Show("HAIR_NOHAT")

        owner.AnimState:Show("HAIR")

        

        owner.AnimState:Show("HEAD")

        owner.AnimState:Hide("HEAD_HAIR")

                

end

 

 local function fn(Sim)

        local inst = CreateEntity()

        local trans = inst.entity:AddTransform()

        local anim = inst.entity:AddAnimState()

        MakeInventoryPhysics(inst)

        

        inst:AddTag("hat")

        

        inst.AnimState:SetBank("footballhat")

        inst.AnimState:SetBuild("logicfilter")

        inst.AnimState:PlayAnimation("anim")

        inst:AddComponent("inspectable")

        inst:AddComponent("equippable")

        inst.components.equippable.equipslot = EQUIPSLOTS.HEAD

    

        inst:AddComponent("inventoryitem")

        inst.components.inventoryitem.atlasname = "images/inventoryimages/logicfilter.xml"

    

        return inst

    end

 

I'm certain I am missing something obvious....

but I have no idea what.

 

I checked the atlas-0.tex, in the logicfilter.zip file and it is good, as best I can tell.

and I used an editor to change the build.bin to the proper name.

I left the anim.bin alone (leaving the default footballhat)

 

A question: Is the zip file you're loading the ground animation or the swap animation for the hat? It seems to me that you're missing the swap animation for your hat.

A question: Is the zip file you're loading the ground animation or the swap animation for the hat? It seems to me that you're missing the swap animation for your hat.

 

I copied the football hat zip so it should have both,

the graphic (atlas-0.tex) shows both the ground and equipped images.

 

is the swap animation file defined seperately?

Not for hats, no. Just hand-held items.

 

Oh, I could've sworn hats had it too. I feel silly.

 

@MidrealmDM

Actually, it's simple, sorry.

inst.components.equippable:SetOnEquip(onequip)inst.components.equippable:SetOnUnequip(onunequip)
Edited by debugman18

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...