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