Jump to content

Help: Multiple Sanity Drain Instances


Recommended Posts

Hello,

I'm attempting to have two different sources drain sanity without them overriding each other.

The basic setup is the character should lose sanity during the day, dusk would remain normal, and no sanity drain at night.

Along with this they have an alternate mode they can change into by pressing T, this mode drains sanity while you're in it, and when you come out of it it should return back to normal.

The issue I'm running into is using inst.components.sanity.dapperness seems to completely override each instance instead of being added or subtracted from each other.

Any help would be appreciated.

Thank you

Link to comment
Share on other sites

I've resolved this issue. Instead of using  inst.components.sanity.dapperness  to set the sanity drain during the day I setup a custom function for sanity drain.

local function sanityfn(inst)
    local delta = 0
    if TheWorld.state.isday then
            delta = TUNING.SANITY_NIGHT_MID
    end
    return delta
end

 

--This part will go into the Master Postinit

inst.components.sanity.custom_rate_fn = sanityfn

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