Jump to content

Question About Different Tool Skins


Recommended Posts

Hello good people!

Is it possible to reskin a tool (for example the axe and the pickaxe) and have it reskinned for only one character? 
I want to make the tools more primitive for my character Drok the Caveman, but i don't want to create a whole new axe item for him.

All help is appreciated!

-Space Monkey

Link to comment
Share on other sites

Sure. Just use 'AddPrefabPostInit' to add an 'if' statement that checks who the player is, and set the animation to a custom one you made.

--In 'modmain.lua'
AddPrefabPostInit("axe",function(inst)
	if GetPlayer().prefab == "drok" then
		inst.AnimState:SetBank("primativeaxe")
		inst.AnimState:SetBuild("primativeaxe")
		inst.AnimState:PlayAnimation("idle")

		--Since it's equippable, you'll also need to override the 'OnEquip' and 'OnDequip' functions
		--Just copy the relevant code from 'axe.lua', but use a swap animation of your own 
	end
end

You should also put the animations in an 'Assets' table in 'modmain.lua'. Make sure it is not a local table though.

Link to comment
Share on other sites

37 minutes ago, Arkathorn said:

Sure. Just use 'AddPrefabPostInit' to add an 'if' statement that checks who the player is, and set the animation to a custom one you made.


--In 'modmain.lua'
AddPrefabPostInit("axe",function(inst)
	if GetPlayer().prefab == "drok" then
		inst.AnimState:SetBank("primativeaxe")
		inst.AnimState:SetBuild("primativeaxe")
		inst.AnimState:PlayAnimation("idle")

		--Since it's equippable, you'll also need to override the 'OnEquip' and 'OnDequip' functions
		--Just copy the relevant code from 'axe.lua', but use a swap animation of your own 
	end
end

You should also put the animations in an 'Assets' table in 'modmain.lua'. Make sure it is not a local table though.

Thanks! That sounds simple enough! How do i override the OnEquip and OnDequip function though? It's been a while since i had a go at modding. Would using this method also make it possible to alter the dropped texture without changing the default axe (with a thought of making it DST compatible, so axes crafted by other players still look like the normal one)?
Thank you for your time! :)

26 minutes ago, Mobbstar said:

It's probably worth noting that DST supports item skins (e.g. backpack), so those might clash with your item if you decide to make them DST compatible.

I'm guessing if i name the animation "primitiveaxe" it wouldn't interfere with other skins right? :p

Link to comment
Share on other sites

Okay, i need some more help.

This is what i have done right now:
 

(...)
    Asset("ANIM", "anim/primitiveaxe.zip"),
    Asset("ATLAS", "images/inventoryimages/primitiveaxe.xml"),

    Asset("ANIM", "anim/swap_primitiveaxe.zip"),
(...)


AddPrefabPostInit("axe",function(inst)
    if GLOBAL.GetPlayer().prefab == "drok" then
        inst.AnimState:SetBank("primitiveaxe")
        inst.AnimState:SetBuild("primitiveaxe")
        inst.AnimState:PlayAnimation("idle")

        local function onequip(inst, owner) 
            owner.AnimState:OverrideSymbol("swap_object", "swap_primitiveaxe", "swap_primitiveaxe")
            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
    end
end)

For some reason it still won't work, can someone please take a look at this?

The ground animation is invisible for Drok, but when i play as Wilson you can see it. So i guess that's a small step in the right direction.

Thanks for your help in advance!

Link to comment
Share on other sites

Okay, everything is working except when the character holds his axe he holds an invisible axe, My question now is how do i  get the animation to work?

I renamed the build to swap_primitiveaxe, so the build name is correct.

Any help here?
Thanks a lot!

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