Jump to content

Recommended Posts

local SANITY_THRESHOLD = 30 -- The amount of sanity the character needs to transform.

inst.tranformed = false

local function SanityTransform(inst)
      if inst.components.sanity
            if not inst.transformed and  inst.components.sanity.current <= SANITY_THRESHOLD
                inst.transformed = true
                -- Code to Tranform
            elseif  inst.transformed then
                inst.transformed = false
                -- Code to Untransform.
            end
      end
end
    
inst:ListenForEvent("sanitydelta",  SanityTransform)

Maybe this doesn't apply the transformation in world load, then you'll need to save the variable inst.transformed in the inst.OnSave fn and check it in the inst.OnLoad fn. Or simple call the SanityTransform fn in entity creation (below Listen to Event), and if it doesn't work, try call it in inst.OnLoadPostPast fn.

Edited by Leonidas IV
  • Like 2
3 hours ago, Leonidas IV said:

local SANITY_THRESHOLD = 30 -- The amount of sanity the character needs to transform.

inst.tranformed = false

local function SanityTransform(inst)
      if inst.components.sanity
            if not inst.transformed and  inst.components.sanity.current <= SANITY_THRESHOLD
                inst.transformed = true
                -- Code to Tranform
            elseif  inst.transformed then
                inst.transformed = false
                -- Code to Untransform.
            end
      end
end
    
inst:ListenForEvent("sanitydelta",  SanityTransform)

Maybe this doesn't apply the transformation in world load, then you'll need to save the variable inst.transformed in the inst.OnSave fn and check it in the inst.OnLoad fn. Or simple call the SanityTransform fn in entity creation (below Listen to Event), and if it doesn't work, try call it in inst.OnLoadPostPast fn.

Thank youu, although it's still unclear to me how do I make my character change textures after transforming, any help?

1 hour ago, Chinken said:

Thank youu, although it's still unclear to me how do I make my character change textures after transforming, any help?

Wilba, for example, changes its build:

inst.AnimState:SetBuild("werewilba")

 

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