Clothilde Vn Posted April 28, 2023 Share Posted April 28, 2023 Hello everyone, I'm trying to create a character based on light/sun. She is able to gain sanity during day, (and she'll lose sanity during night like everyone else). I tried this script, but my character is always regenerating sanity all the time (day, dusk or night). I searched on this forum, but could'nt get any answers which is working for me. This is the script I made : local function sanityDay(inst) if TheWorld.state.isday then inst.components.sanity.dapperness = 2 else inst.components.sanity.dapperness = 0 end end Could you help me to fix it please? Link to comment https://forums.kleientertainment.com/forums/topic/147464-dst-characters-mods-script-gain-sanity-from-day/ Share on other sites More sharing options...
Clothilde Vn Posted April 28, 2023 Author Share Posted April 28, 2023 (edited) I finally understood: So here the function: local function SanityRegen(inst) if TheWorld.state.isday then inst.components.sanity.dapperness = 2 else inst.components.sanity.dapperness = 0 end end And here the call to the function in local master_postinit = function(inst) inst:DoPeriodicTask( 0.0, function(inst) SanityRegen(inst) end) I hope it will help some other people! If a moderator see this. You can close the topic Best regards. Edited April 28, 2023 by Clothilde Vn Link to comment https://forums.kleientertainment.com/forums/topic/147464-dst-characters-mods-script-gain-sanity-from-day/#findComment-1632537 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