Jump to content

Recommended Posts

Hey-ho!

I would like to make my custom character change it's certain textures based on his Sanity level - similarly as Wolfgang does, but without any game/stat changing effect.

How should the coding and the image file arrangement look like?

Thanks in advance!

Edited by BillTheCipher

Howdy!

Inside of CHARACTERNAMEHERE.lua goes:

 

Quote

local assets

	Asset( "ANIM", "anim/NAMEOFEXPORTEDFOLDERnumber1.zip" ),
	Asset( "ANIM", "anim/NAMEOFEXPORTEDFOLDERnumber2.zip" ),
	Asset( "ANIM", "anim/NAMEOFEXPORTEDFOLDERnumber3.zip" ),
Quote

somewhere below local assets but not inside master_postinit



local function changemymind(inst)
local sanity = inst.components.sanity.current

if inst:HasTag("playerghost") then return end
if inst.components.health:IsDead() then return end

	-- stage I (0-50 sanity)
	if sanity <= 50 then
		inst.AnimState:SetBuild("NAMEOFEXPORTEDFOLDERnumber1")
	end
	
	-- stage II (51-100 sainity)
	if sanity >= 51 and sanity <= 100 then
		inst.AnimState:SetBuild("NAMEOFEXPORTEDFOLDERnumber2")		
	end
	
	-- stage III (over 100 sanity)
	if sanity >= 101 then
		inst.AnimState:SetBuild("NAMEOFEXPORTEDFOLDERnumber3")		
	end
end
Quote

master_posinit

	inst:ListenForEvent("sanitydelta", changemymind)

 

If you have any questions or you will encounter any poroblems, let me know and I will try to fix my mistakes. Cheers!

  • Thanks 1

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