Jump to content

Help with invisible equipable


Recommended Posts

5 hours ago, Lumina said:

Probably related to the anim swap_item. How do you made the anim ? How is your code looking ?

local assets =

    Asset("ANIM", "anim/cactuspike.zip"),
    Asset("ANIM", "anim/swap_cactuspike.zip"), 

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

local function OnEquip(inst, owner) 
    owner.AnimState:OverrideSymbol("swap_object", "swap_cactuspike", "cactuspike")
    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(colour)
    local inst = CreateEntity()

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

    MakeInventoryPhysics(inst)
   
    inst.AnimState:SetBank("cactuspike")
    inst.AnimState:SetBuild("cactuspike")
    inst.AnimState:PlayAnimation("idle")
    
    inst.entity:SetPristine()
 
    if not TheWorld.ismastersim then
        return inst
    end    

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

    local cactuspike_damage = 65
    
    inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(cactuspike_damage)
    inst.components.weapon:SetRange(1)
    
    inst:AddComponent("finiteuses")
    inst.components.finiteuses:SetMaxUses(200)
    inst.components.finiteuses:SetUses(200)
    inst.components.finiteuses:SetOnFinished(inst.Remove)

    return inst
end

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

Link to comment
Share on other sites

@MauroxyBofoxez Ok, i think you need another folder named "swap_cactuspike" into the already existing "swap_cactuspike", and your .png in this folder. This to allows the .png file to be used as a "symbol". At least it's how i understand the structure of the tutorial you followed.

Better to make a clean .scml project from scratch.

 

And i think this line should be changed :


    owner.AnimState:OverrideSymbol("swap_object", "swap_cactuspike", "cactuspike")

to :


    owner.AnimState:OverrideSymbol("swap_object", "swap_cactuspike", "swap_cactuspike")

 

I'm not entirely sure, but it worth a try.

Link to comment
Share on other sites

I think it will help with an update tutorial. Old topics on forum have strange problem with structure of code, and it makes it harder to read, so people do more mistakes. I'm not saying people shouldn't search, but i think that it doesn't help.

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