Jump to content

Custom Item invisibile no matter what


Recommended Posts

I've been trying to create a custom item based on the umbrella from the game A Hat in Time for days now, but I've been hitting the same problem every time I try to work on it. The texture of the item, no matter if I use a texture from the game itself, or a custom texture I supply, is invisible, I'm assuming this a script problem, but I have no idea what could be causing it. Here's my script.

local assets =
{
    Asset("ANIM", "anim/hatbrella2.zip"),
    Asset("ANIM", "anim/swap_hatbrella2.zip"),
    Asset("ATLAS", "images/inventoryimages/hatbrella2.xml"),
    Asset("IMAGE", "images/inventoryimages/hatbrella2.tex"),
}

local function OnEquip(inst, owner)
    --owner.AnimState:OverrideSymbol("swap_object", "swap_wands", "purplestaff")
	owner.AnimState:OverrideSymbol("swap_object", "swap_hatbrella2", "swap_hatbrella2")
    owner.AnimState:Show("ARM_carry")
    owner.AnimState:Hide("ARM_normal")
end
  
local function OnUnequip(inst, owner)
    owner.AnimState:Hide("ARM_carry")
    owner.AnimState:Show("ARM_normal")
end
 
local function fn()
  
    local inst = CreateEntity()
 
    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()
	inst.entity:AddMiniMapEntity()
     
    MakeInventoryPhysics(inst)   
      
    inst.AnimState:SetBank("hatbrella2")
    inst.AnimState:SetBuild("swap_hatbrella2")
    inst.AnimState:PlayAnimation("idle")
	
    inst:AddTag("sharp")
	inst:AddTag("waterproofer")
	
    inst:AddComponent("waterproofer")	
    inst.components.waterproofer:SetEffectiveness(TUNING.WATERPROOFNESS_HUGE)

    inst:AddComponent("insulator")
    inst.components.insulator:SetSummer()
    inst.components.insulator:SetInsulation(TUNING.INSULATION_MED)
	
    if not TheWorld.ismastersim then
        return inst
    end
 
    inst.entity:SetPristine()

    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(TUNING.HATBRELLA_DAMAGE)
  
    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "hatbrella2"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/hatbrella2.xml"
	
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )
	
	MakeHauntableLaunch(inst)
	
    return inst
end
return  Prefab("common/inventory/hatbrella2", fn, assets) 

 

Link to comment
Share on other sites

Comparing your code to my code I see that you should set your build to inst.AnimState:SetBuild("hatbrella2"). I don't really know how your animation looks in Spriter but try this and then tell me if it works.

  • Like 2
Link to comment
Share on other sites

13 hours ago, IThatGuyI said:

Comparing your code to my code I see that you should set your build to inst.AnimState:SetBuild("hatbrella2"). I don't really know how your animation looks in Spriter but try this and then tell me if it works.

That's how it is normally, without the swap_ part in the build name, I just added it in case it worked. I've been trying to get this to work for days, JUST ONE TEXTURE.

Link to comment
Share on other sites

10 hours ago, IThatGuyI said:

There, apparently, was an error in the .scml file, as expected. Here, use this folder in exported instead of yours:

 

swap_hatbrella2.rar 19.8 kB · 0 downloads

Oh my god! Finally it works! You're a freaking lifesaver dude. What was the error out of curiosity?

Edited by DocterRedstone
So I didn't look like a jerk lol
  • Like 1
Link to comment
Share on other sites

1 hour ago, DocterRedstone said:

What was the error out of curiosity?

Honestly, I don't know. I just made a new swap_hatbrell2.scml with your image and it worked. At least you know it was an error with the .scml file and not with the script.

  • Like 2
Link to comment
Share on other sites

1 hour ago, IThatGuyI said:

Honestly, I don't know. I just made a new swap_hatbrell2.scml with your image and it worked. At least you know it was an error with the .scml file and not with the script.

Well then lol, thank you. I'm gonna close all my threads now haha

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...