Jump to content

Recommended Posts

Hi, I'm making characters for my French-speaking friends and today I was trying to find a right template for one's hat. I have encountered three problems though:

 

-When placing it on the ground, the hat disappears

-I don't know how I can name the item

-The characters' headbase seems to disappear upon equipping (tested with Wilson)

 

Besides, I'd also like to know how to put it with in my character mod.

 

Edit: How do I attach the mod file to this forum?  :lemo:

Edited by Thibooms
Link to comment
https://forums.kleientertainment.com/forums/topic/53406-help-hat-mod/
Share on other sites

- Likely the build has a different name or the asset wasn't loaded

- You need to put GLOBAL.STRINGS.(your hat prefab in upper case letters) = "My Hat Name"

- You need to put an onequip and onunequip functions that alter the character's AnimState, like any other hat.

 

You drop the hat file with your character file, combine the modmains, and you add the hat prefab to the PrefabFiles in the main modmain.

 

Click "Reply to this topic" or "More Reply Options" to see the attachment options at the bottom of the post.

Thank you for the help!

 

-I would like to show you that everything was renamed, maybe you'll stumble on some mistake I didn't see

-Where do I put that? In scripts/prefabs/lua file?

-I have no experience at all with items (aside from beards, if that counts...), I have no idea how to do that, sorry ^^'. Also, this very issue also happens with the tutorial mod so... :/

 

Thanks :-)

 

I tried that the first time, but it says I can't upload that type of file. I tried a Winrar format by the way. I don't know what other way to attach the mod (there are also no new textures, it's still the tutorial's)

 

PS: I used as a template the "Hat Tutorial" by Ysovuka

Edited by Thibooms

- Yes, renaming things tend to break everything

- In modmain

- Hats have this code:

    local function onequip(inst, owner, fname_override)        local build = fname_override or fname        owner.AnimState:OverrideSymbol("swap_hat", build, "swap_hat")        owner.AnimState:Show("HAT")        owner.AnimState:Show("HAT_HAIR")        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("HAT_HAIR")        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		inst:AddComponent("equippable")	inst.components.equippable.equipslot = EQUIPSLOTS.HEAD	inst.components.equippable:SetOnEquip(onequip)	inst.components.equippable:SetOnUnequip(onunequip)

 

Upload .lua files or .zip files. In winrar, instead of rar, pick zip.

Canotier_Lionel.zip

 

-I attached the file, maybe you can have a look at it?

-Thanks, done  :lemo: Buuuut it seems to crash now because of that line. "<name> expected near '('" even though I did that.

-It seems that that code is already present. I don't personnally see what could be wrong with it.  :nightmare:

 

FYI: the prefab name is "canotier_lionel"

Edited by Thibooms

You are awesome, DarkXero! Thank you very much for your help.

 

The hat now doesn't disappear anymore and the onequip/unequip stuff works just fine. Though it still says "MISSING NAME" in the invenotry.
 

I only need to know how to fix that now, thank you again!

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