Jump to content

Recommended Posts

Hey hey, I'm here to admit that coding isn't my forte.

So I'm attempting to create a downside, one I believed would be simple, but I don't know my way around the DST code. So I have thus far been unable to find success despite finishing pretty much every other part of the mod. The basic idea is this:

"If Sanity is below 50 then Drain 5 Sanity per second."

I'll figure out the balance later, but the idea is to act as a punishment for neglecting the stat, and to make it challenging to come back from the low.

If anyone could lend their experience on this one, it would be much appreciated!

:wickerbottomthanks:

Try putting this under the "master_postinit" function:

inst.components.sanity.custom_rate_fn = sanityfn

Then call the "sanityfn" function outside of it.
 

local function sanityfn(inst) 
  	local sanity_tresh = inst.components.sanity.current 

	return sanity_tresh <= 50 and -5/60 or 0 -- if sanity is lower or equal than 50, reduce 5 sanity per minute, else, do nothing. 
end

I hope this helps!

  • Thanks 1
1 hour ago, HarryPPP said:

I hope this helps!

You nailed it! Cheers!

Tested it in a few ways to make sure, and unless my own sanity dropped that fast, it performed as expected. I'll send you a cookie for the help!

:wilson_love:

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