Jump to content

DST Characters Mods Script : gain sanity from day


Recommended Posts

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
Share on other sites

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 by Clothilde Vn
Link to comment
Share on other sites

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
 Share

×
  • Create New...