Jump to content

(Solved) Need help with disabling natural Sanity Change at Dusk


Recommended Posts

I cannot disable any kind of natural sanity drain/gain when at dusk, even if I set the negative dusk drain to zero. I thought that this was tied to the night drain, as I realized sanity would be gained when I had the night drain reversed, so I made code that changes sanity drain change at different times of the day, but it didn't work. I don't know what I am doing wrong, and I need some help with this.

Here is that code I used in case if anyone wants to look at it. (I made it into a comment for the time being)

--[[ local function SanityDrainThing(inst) 
		if TheWorld.state.isnight or TheWorld.state.iscavenight then
			inst.components.sanity.night_drain_mult = -1.15
			inst.components.sanity.dusk_drain_mult = 0
		else
			inst.components.sanity.night_drain_mult = 0
			inst.components.sanity.dusk_drain_mult = 0
		end
	end ]]--

 

Edited by Earthyburt
Link to comment
Share on other sites

@Earthyburt
I think you're using the right code.

inst.components.sanity.night_drain_mult = 

It's the same as what I use.  I suspect something else is causing a sanity drain, or else it's defaulting to telling you it's dropping even when it isn't.  I made a sleeping bag that had no hunger drain but it still claims there's a drain.

Edited by FurryEskimo
  • Thanks 1
Link to comment
Share on other sites

58 minutes ago, FurryEskimo said:

@Earthyburt
I think you're using the right code.


inst.components.sanity.night_drain_mult = 

It's the same as what I use.  I suspect something else is causing a sanity drain, or else it's defaulting to telling you it's dropping even when it isn't.  I made a sleeping bag that had no hunger drain but it still claims there's a drain.

I checked if that is the case, and unfortunately it's not, my character's sanity changes during dusk

Link to comment
Share on other sites

On 2/28/2021 at 9:07 PM, penguin0616 said:

Is your code actually running?

inst.components.sanity.night_drain_mult = 0 appears to be correct.

I am dumb, and I forgot to set back to the altered code.

Still didn't work anyways, nice. Let me double check the code

Edited by Earthyburt
  • Like 1
Link to comment
Share on other sites

10 hours ago, penguin0616 said:

Assuming you mean it still didn't work, I suggest adding prints to be very sure that it is running.

Aha! I found the problem: I needed to have a DoPeriodicTask component attached to the function. It works now, thank you for your help! I appreciate it!

  • Like 1
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...