TheAlphaDehur Posted October 30, 2021 Share Posted October 30, 2021 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! Link to comment https://forums.kleientertainment.com/forums/topic/134945-solvedmaking-sanity-drain-at-a-threshold/ Share on other sites More sharing options...
HarryPPP Posted October 31, 2021 Share Posted October 31, 2021 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! 1 Link to comment https://forums.kleientertainment.com/forums/topic/134945-solvedmaking-sanity-drain-at-a-threshold/#findComment-1509347 Share on other sites More sharing options...
TheAlphaDehur Posted October 31, 2021 Author Share Posted October 31, 2021 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! Link to comment https://forums.kleientertainment.com/forums/topic/134945-solvedmaking-sanity-drain-at-a-threshold/#findComment-1509356 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now