Jump to content

Recommended Posts

Hi! I've been having a lot of fun since I got into don't starve modding, and I've already made a couple of character mods, but they aren't quite finished yet. The problem I'm having with both mods is that the custom items I gave them don't appear while they're equipped. The inventory icon, and the sprite for when they're dropped on the floor work perfectly fine. Although for whatever reason, when I equip the item to be worn or held, it's invisible, but functioning. I've looked at a lot of different mods that add items, and I don't see any difference between my code and theirs aside from the filenames. Please help me!

Here is the code for one of my items.

Spoiler

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

local function OnBlocked(owner) 
    owner.SoundEmitter:PlaySound("dontstarve/wilson/hit_armour")
end

local function onequip(inst, owner) 
    owner.AnimState:OverrideSymbol("swap_body", "elinecklace", "swap_body")
    inst:ListenForEvent("blocked", OnBlocked, owner)
end

local function onunequip(inst, owner) 
    owner.AnimState:ClearOverrideSymbol("swap_body")
    inst:RemoveEventCallback("blocked", OnBlocked, owner)
end

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

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

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

    inst:AddTag("jewlery")

    inst.foleysound = "dontstarve/movement/foley/jewlery"

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    inst:AddComponent("inspectable")

    inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.imagename = "elinecklace"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/elinecklace.xml"
	
	inst:AddComponent("combat")
	inst.components.combat.damagemultiplier = 1.5

    inst:AddComponent("armor")
    inst.components.armor:InitCondition(TUNING.ARMORWOOD, TUNING.ARMORWOOD_ABSORPTION)

    inst:AddComponent("equippable")
    inst.components.equippable.equipslot = EQUIPSLOTS.BODY
	inst.components.equippable.dapperness = TUNING.DAPPERNESS_SMALL

    inst.components.equippable:SetOnEquip(onequip)
    inst.components.equippable:SetOnUnequip(onunequip)

    MakeHauntableLaunch(inst)

    return inst
end

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

 

 

swap_elinecklace.zip

Edited by shirusnake
I added my swap image/.scml file just in case there is an issue there.
Link to comment
https://forums.kleientertainment.com/forums/topic/83527-help-with-custom-items/
Share on other sites

Usually this come for the structure of the spriter folder.


Do you have something like this :

 

a swap_item folder, containing :

swap_item.scml

swap_item folder

 

and the second swap_item folder containing

swap_item.png

 

?

 

If yes, please attach your entire mod. If no, please try following this structure.

2 hours ago, Lumina said:

Usually this come for the structure of the spriter folder.


Do you have something like this :

 

a swap_item folder, containing :

swap_item.scml

swap_item folder

 

and the second swap_item folder containing

swap_item.png

 

?

 

If yes, please attach your entire mod. If no, please try following this structure.

Thank you very much for your timely reply! :]

Originally I only had a swap_item folder containing both the .scml and .png, but after fixing it as you suggested, I don't see any change. :(

Here is my entire mod. I hope mediafire links are allowed on this forum!

https://www.mediafire.com/file/vsw9b9z9w46cov2/eli.zip

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