Jump to content

Custom weapon is invisible when equipped?


Recommended Posts

Hello again, 

Following on the previous post, I managed to get the spear to work in game. The problem is that the spear is visible in the inventory and when dropped on the floor, but when equipped it turns invisible but is still usable. I also can't seem to inspect the item when it's dropped but I can when it is in my inventory?

Any help? 

Script for the spear:

Quote

local assets=

    Asset("ANIM", "anim/wakes_spear.zip"),
    Asset("ANIM", "anim/wakes_spear_swap.zip"), 

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

local prefabs = 
{
}

local function fn(colour)

    local function OnEquip(inst, owner) 
        --owner.AnimState:OverrideSymbol("swap_object", "swap_wands", "purplestaff")
        owner.AnimState:OverrideSymbol("swap_object", "wakes_spear_swap", "wakes_spear")
        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 inst = CreateEntity()
    local trans = inst.entity:AddTransform()
    local anim = inst.entity:AddAnimState()
    MakeInventoryPhysics(inst)
    
    
    anim:SetBank("wakes_spear")
    anim:SetBuild("wakes_spear")
    anim:PlayAnimation("idle")
    
    inst:AddComponent("inspectable")
    inst:AddTag("sharp")
    
    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE*1.25)
    
    inst:AddComponent("finiteuses")
    inst.components.finiteuses:SetMaxUses(TUNING.SPEAR_USES*1.35)
    inst.components.finiteuses:SetUses(TUNING.SPEAR_USES*1.35)
    
    inst:AddComponent("waterproofer")
    inst.components.waterproofer.effectiveness = 0

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "wakes_spear"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/wakes_spear.xml"
    
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )

    return inst
end

return  Prefab("common/inventory/wakes_spear", fn, assets, prefabs)

The file structure for the files looks like:

wakes_spear_swap(Folder) --> wakes_spear_swap(spriter file), wakes_spear_swap(folder) --->wakes_spear_swap.png

20190604035848_1.jpg

Link to comment
Share on other sites

The code looks mainly right for the weapon file, as for your problem its one of the two problems I usually see in the forums. One is that the person made a scml file from complete scratch (no template) and tried to make it work on don't starve which doesn't work. Two is that the: anim:SetBuild("wakes_spear") may be the wrong build as its usually what the build name in the spriter file is (reference the build picture). The other problems are usually too rare to mention. Looking at your previous post you could modify the wand.png to be bigger just by replacing it with a png with the same name but a bigger resolution. There is a wand modified zip I attached if your interested and the capture.png reference on the spriter where the character's hand goes, on the red dot.

wandmodified.zip

buildpicture.PNG

Capture.PNG

Link to comment
Share on other sites

Aha! Thank you for clearing that up, I narrowed it down to 'owner.AnimState:OverrideSymbol("swap_object", "wakes_spear_swap", "wakes_spear")' which should actually be owner.AnimState:OverrideSymbol("swap_object", "wakes_spear_swap", "wand"). Thank you.

20190609014735_1.jpg

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...