Earthyburt 46 Report post Posted February 28 (edited) 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 March 5 by Earthyburt Share this post Link to post Share on other sites
FurryEskimo 39 Report post Posted March 1 (edited) @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 March 1 by FurryEskimo 1 Share this post Link to post Share on other sites
Earthyburt 46 Report post Posted March 1 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 Share this post Link to post Share on other sites
penguin0616 914 Report post Posted March 1 Is your code actually running? inst.components.sanity.night_drain_mult = 0 appears to be correct. 2 Share this post Link to post Share on other sites
Earthyburt 46 Report post Posted March 5 (edited) 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 March 5 by Earthyburt 1 Share this post Link to post Share on other sites
penguin0616 914 Report post Posted March 5 Assuming you mean it still didn't work, I suggest adding prints to be very sure that it is running. 1 1 Share this post Link to post Share on other sites
Earthyburt 46 Report post Posted March 5 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! 1 Share this post Link to post Share on other sites
FurryEskimo 39 Report post Posted March 5 Congrats!! I think you can get away with putting it in the character’s prefab, in the ‘master_postinit’ Share this post Link to post Share on other sites