Jump to content

Recommended Posts

I'm creating a new prefab, but it uses the hardwood hat appearance, but I have a problem, when I drop the item on the ground, it becomes invisible. I imagine the problem could be SetBank and SetBuild, but I've already tested all the combinations with hat_woodcarved, woodcarvedhat and just woodcarved, nothing changed.

local assets =
{
	Asset("ANIM", "anim/hat_woodcarved.zip"),
}

local function OnEquip(inst, owner)
    owner.AnimState:OverrideSymbol("swap_hat", "hat_woodcarved", "swap_hat")

    owner.AnimState:Show("HAT")
    owner.AnimState:Show("HAIR_HAT")
    owner.AnimState:Hide("HAIR_NOHAT")
    owner.AnimState:Hide("HAIR")

    if owner:HasTag("player") then
        owner.AnimState:Hide("HEAD")
        owner.AnimState:Show("HEAD_HAT")
    end
end

local function OnUnequip(inst, owner)
    owner.AnimState:Hide("HAT")
    owner.AnimState:Hide("HAIR_HAT")
    owner.AnimState:Show("HAIR_NOHAT")
    owner.AnimState:Show("HAIR")

    if owner:HasTag("player") then
        owner.AnimState:Show("HEAD")
        owner.AnimState:Hide("HEAD_HAT")
    end
end

local function fn()
    local inst = CreateEntity()
    
    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

    inst:AddTag("hat")
    inst:AddTag("wood")

    inst.AnimState:SetBank("hat_woodcarved")
    inst.AnimState:SetBuild("hat_woodcarved")
    inst.AnimState:PlayAnimation("idle")

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    MakeHauntableLaunch(inst)

    inst:AddComponent("inspectable")
	
    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.atlasname = "images/inventoryimages3.xml"
    inst.components.inventoryitem.imagename = "woodcarvedhat"

    inst:AddComponent("tradable")
	
    inst:AddComponent("armor")
    inst.components.armor:InitCondition(TUNING.ARMOR_WOODCARVED_HAT, TUNING.ARMORGRASS_ABSORPTION)
    inst.components.armor:AddWeakness("beaver", TUNING.BEAVER_WOOD_DAMAGE)

    inst:AddComponent("fuel")
    inst.components.fuel.fuelvalue = TUNING.LARGE_FUEL

    MakeSmallBurnable(inst, TUNING.SMALL_BURNTIME)
    MakeSmallPropagator(inst)

    inst:AddComponent("equippable")
    inst.components.equippable.equipslot = EQUIPSLOTS.HEAD
    inst.components.equippable:SetOnEquip(OnEquip)
    inst.components.equippable:SetOnUnequip(OnUnequip)

    return inst
end

return Prefab("common/inventory/carvedhat", fn, assets)

 

If after throwing it you can still pick up the object the yeah, maybe the bank. I'll tell you how (I think) it works.

On your Spriter it should look like this:

image.png.0970059f1ee5b670340742f4119d6e6e.png

then make sure that when you start your don't starve (and don't have the "ANIM" folder) it does this with your scml name file:

image.png.b71f5e4d3d5ea9817c8c6851af003529.png

Next, check that there's a .zip file in the same folder as your scml file. Open it, and it should look like this:

image.png.16e05581cd001dcb1f7c5ec24e42ee7d.png

Then in the code put the name that appears as "root" in the animation.xml file

    inst.AnimState:SetBank("hunterhat_BANK")
    inst.AnimState:PlayAnimation("idle")

and in the game:

image.png.d4bbc4c8f4b9ae6358c0c1a2d05810aa.png

  • Like 1

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