Jump to content

Recommended Posts

You should investigate Willow's file for this, she does the same for a lack of sanity but freezes instead.

Willow's specific code:

-- as part of the easing functionality, please include:
local easing = require("easing")



-- This is the called from function (un-modified from willows)
-- Search in the TUNING.lua file found in the data folder of DST to find references to the values such as "TUNING.WILLOW_CHILL_START"

local function UpdateSanityTemperature(inst)
    --Don't chill all the way to 0, or temperature
    --update fluctuations can still cause freezing
    if TheWorld.state.temperature > 1 then
        local sanity = inst.components.sanity:GetPercent()
        if sanity < TUNING.WILLOW_CHILL_START then
            inst.components.temperature:SetModifier(
                "sanity",
                math.max(
                    1 - TheWorld.state.temperature,
                    sanity > TUNING.WILLOW_CHILL_END and
                    easing.outQuad(sanity - TUNING.WILLOW_CHILL_END, TUNING.WILLOW_SANITY_CHILLING, -TUNING.WILLOW_SANITY_CHILLING, TUNING.WILLOW_CHILL_START - TUNING.WILLOW_CHILL_END) or
                    TUNING.WILLOW_SANITY_CHILLING
                )
            )
            return
        end
    end

    inst.components.temperature:RemoveModifier("sanity")
end
          
--[[ 
-- inst.components.temperature:SetModifier() -- the function that you should handle
-- if the function states return - it ends the function (if condition isn't met "sanity modifier" is removed)
                 math.max(
                    1 - TheWorld.state.temperature,
                    sanity > TUNING.WILLOW_CHILL_END and
                    easing.outQuad(sanity - TUNING.WILLOW_CHILL_END, TUNING.WILLOW_SANITY_CHILLING, -TUNING.WILLOW_SANITY_CHILLING, TUNING.WILLOW_CHILL_START - TUNING.WILLOW_CHILL_END) or
                    TUNING.WILLOW_SANITY_CHILLING
                )         
]]

----
-- Main master fn for your character
---
local function master_postinit(inst)
	-- from Willow's
    inst:DoPeriodicTask(.1, UpdateSanityTemperature, 0)
end

 

Edited by MorickClive
3 hours ago, MorickClive said:

You should investigate Willow's file for this, she does the same for a lack of sanity but freezes instead.

Willow's specific code:


-- as part of the easing functionality, please include:
local easing = require("easing")



-- This is the called from function (un-modified from willows)
-- Search in the TUNING.lua file found in the data folder of DST to find references to the values such as "TUNING.WILLOW_CHILL_START"

local function UpdateSanityTemperature(inst)
    --Don't chill all the way to 0, or temperature
    --update fluctuations can still cause freezing
    if TheWorld.state.temperature > 1 then
        local sanity = inst.components.sanity:GetPercent()
        if sanity < TUNING.WILLOW_CHILL_START then
            inst.components.temperature:SetModifier(
                "sanity",
                math.max(
                    1 - TheWorld.state.temperature,
                    sanity > TUNING.WILLOW_CHILL_END and
                    easing.outQuad(sanity - TUNING.WILLOW_CHILL_END, TUNING.WILLOW_SANITY_CHILLING, -TUNING.WILLOW_SANITY_CHILLING, TUNING.WILLOW_CHILL_START - TUNING.WILLOW_CHILL_END) or
                    TUNING.WILLOW_SANITY_CHILLING
                )
            )
            return
        end
    end

    inst.components.temperature:RemoveModifier("sanity")
end
          
--[[ 
-- inst.components.temperature:SetModifier() -- the function that you should handle
-- if the function states return - it ends the function (if condition isn't met "sanity modifier" is removed)
                 math.max(
                    1 - TheWorld.state.temperature,
                    sanity > TUNING.WILLOW_CHILL_END and
                    easing.outQuad(sanity - TUNING.WILLOW_CHILL_END, TUNING.WILLOW_SANITY_CHILLING, -TUNING.WILLOW_SANITY_CHILLING, TUNING.WILLOW_CHILL_START - TUNING.WILLOW_CHILL_END) or
                    TUNING.WILLOW_SANITY_CHILLING
                )         
]]

----
-- Main master fn for your character
---
local function master_postinit(inst)
	-- from Willow's
    inst:DoPeriodicTask(.1, UpdateSanityTemperature, 0)
end

 

Thanks for the quick reply i shall experiment with this first thing in the morning. ^_^

On 2017-6-7 at 8:58 PM, MorickClive said:

You should investigate Willow's file for this, she does the same for a lack of sanity but freezes instead.

Willow's specific code:


-- as part of the easing functionality, please include:
local easing = require("easing")



-- This is the called from function (un-modified from willows)
-- Search in the TUNING.lua file found in the data folder of DST to find references to the values such as "TUNING.WILLOW_CHILL_START"

local function UpdateSanityTemperature(inst)
    --Don't chill all the way to 0, or temperature
    --update fluctuations can still cause freezing
    if TheWorld.state.temperature > 1 then
        local sanity = inst.components.sanity:GetPercent()
        if sanity < TUNING.WILLOW_CHILL_START then
            inst.components.temperature:SetModifier(
                "sanity",
                math.max(
                    1 - TheWorld.state.temperature,
                    sanity > TUNING.WILLOW_CHILL_END and
                    easing.outQuad(sanity - TUNING.WILLOW_CHILL_END, TUNING.WILLOW_SANITY_CHILLING, -TUNING.WILLOW_SANITY_CHILLING, TUNING.WILLOW_CHILL_START - TUNING.WILLOW_CHILL_END) or
                    TUNING.WILLOW_SANITY_CHILLING
                )
            )
            return
        end
    end

    inst.components.temperature:RemoveModifier("sanity")
end
          
--[[ 
-- inst.components.temperature:SetModifier() -- the function that you should handle
-- if the function states return - it ends the function (if condition isn't met "sanity modifier" is removed)
                 math.max(
                    1 - TheWorld.state.temperature,
                    sanity > TUNING.WILLOW_CHILL_END and
                    easing.outQuad(sanity - TUNING.WILLOW_CHILL_END, TUNING.WILLOW_SANITY_CHILLING, -TUNING.WILLOW_SANITY_CHILLING, TUNING.WILLOW_CHILL_START - TUNING.WILLOW_CHILL_END) or
                    TUNING.WILLOW_SANITY_CHILLING
                )         
]]

----
-- Main master fn for your character
---
local function master_postinit(inst)
	-- from Willow's
    inst:DoPeriodicTask(.1, UpdateSanityTemperature, 0)
end

 

Thanks a lot, i forgot about willow. i just copied her code and changed some numbers around. it wokrs now.

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
×
  • Create New...