Jump to content

Invisible Equipped Weapon


Recommended Posts

10 minutes ago, Lumina said:

Yes, i have possible clues. Can you attach your mod, copy here the code of your weapon and explain how you created the related anim ? Thanks.

Here's the code.

local assets=
{ 
    Asset("ANIM", "anim/pillow.zip"),
    Asset("ANIM", "anim/swap_pillow.zip"), 

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

local prefabs = 
{
}

local function onthrown(inst, data)
    inst.AnimState:SetOrientation(ANIM_ORIENTATION.OnGround)
end


local function fn(colour)

    local function OnEquip(inst, owner)
        owner.AnimState:OverrideSymbol("swap_object", "swap_pillow", "pillow")
        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)
	RemovePhysicsColliders(inst)
	
    anim:SetBank("pillow")
    anim:SetBuild("pillow")
    anim:PlayAnimation("idle", true)
	
	if not TheWorld.ismastersim then
        return inst
    end

	inst:AddComponent("weapon")
	inst.components.weapon:SetDamage(50)
	
    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "pillow"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/pillow.xml"
    
	inst:AddComponent("inspectable")
	
	inst:AddComponent("finiteuses")
	inst.components.finiteuses:SetMaxUses(25)
	inst.components.finiteuses:SetUses(25)
	inst.components.finiteuses:SetOnFinished(inst.Remove)
	
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )

    return inst
end

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

I made the weapon's folders from scratch and let the autocompiler take care of it for me.

Shantae.zip

Link to comment
Share on other sites

@icantevenname

 

There were three problems :

- First, in this specific case, you can't just put things in the autocompiler, you need to follow a very specific structure. As far as i know it's needed so the item will have the right symbol (it's the symbol that allow the placing).

This old tutorial is still valid for the most part :

So i changed the structure of the swap_pillow as needed.

-Second, you can't name things as you want, so again, i followed the guide, and renamed BUILD instead of idle for the swa_pillow.scml project.

- Third, this line needed a change :

        owner.AnimState:OverrideSymbol("swap_object", "swap_pillow", "pillow")

This is the correct line :

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

 

Now the pillow is showing just fine for my tests. Here is the version with all the changes, will be faster than doing yourself again.

Shantae.zip

All should work fine but keep your old version as a backup just in case.

Edited by Lumina
Link to comment
Share on other sites

 

28 minutes ago, Lumina said:

@icantevenname

 

There were three problems :

- First, in this specific case, you can't just put things in the autocompiler, you need to follow a very specific structure. As far as i know it's needed so the item will have the right symbol (it's the symbol that allow the placing).

This old tutorial is still valid for the most part :

So i changed the structure of the swap_pillow as needed.

-Second, you can't name things as you want, so again, i followed the guide, and renamed BUILD instead of idle for the swa_pillow.scml project.

- Third, this line needed a change :


        owner.AnimState:OverrideSymbol("swap_object", "swap_pillow", "pillow")

This is the correct line :


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

 

Now the pillow is showing just fine for my tests. Here is the version with all the changes, will be faster than doing yourself again.

Shantae.zip

All should work fine but keep your old version as a backup just in case.

Thank you so much! This has been bugging me for a long time! I'll bookmark that link.

Link to comment
Share on other sites

Yes, this is very useful to have. Some information can't be guessed and are hard to find outside of this kind of tutorial. The only problem is that the formatting of very old posts is sometimes strange, making it harder to follow them.

Link to comment
Share on other sites

11 hours ago, icantevenname said:

I still don't understand what I'm doing wrong. I did what you told me to do, and I've went up and down that tutorial over and over again. What am I missing?

The image needs to be in a folder inside the folder. Look at the exported file of the other weapon. Keep the exact same structure.

You need to have your swap_weapon folder. Inside, you have your swap_weapon.scml and another swap_weapon folder. This other folder will contain the image.

It's needed to create a symbol.

Link to comment
Share on other sites

5 hours ago, Lumina said:

The image needs to be in a folder inside the folder. Look at the exported file of the other weapon. Keep the exact same structure.

You need to have your swap_weapon folder. Inside, you have your swap_weapon.scml and another swap_weapon folder. This other folder will contain the image.

It's needed to create a symbol.

Thanks so much again! Guess I was too focused on the luas to even consider that. Bet I can do this on my own now!

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