Jump to content

Recommended Posts

Hello, i'm making a custom character for the game, and i want him to lose sanity when above a certain temperature. I have played around with it, searched around, but i cant figure it out. Any help?

I tried using using DoPeriodicTask and checking the temperature, then changing the daperness of the player, but it either crashes my game or makes the "Dedicated server unable to start".

Edited by Navii0
3 hours ago, penguin0616 said:

Listen for "temperaturedelta" on the player for the temperature. For the sanity loss, take a look at Sanity:AddSanityPenalty and Sanity:RemoveSanityPenalty.

I'm new to DST coding, how exactly do i do that?

Edited by Navii0

@Navii0You should take a look at the game's files, which have the actual function definitions that you will be interested in and examples for listening on events. 
This is a guide on Lua 5.1 (in case you are not familiar with it), which is what DST uses. http://www.lua.org/manual/5.1/

  • Like 1
16 hours ago, penguin0616 said:

@Navii0You should take a look at the game's files, which have the actual function definitions that you will be interested in and examples for listening on events. 
This is a guide on Lua 5.1 (in case you are not familiar with it), which is what DST uses. http://www.lua.org/manual/5.1/

I did look at the game files, but i could not figure anything out. I looked at another mod that uses temperature in their character, i copy pasted their code into my character, and it still crashed my game.

Aight, i got it working. I made a function

local function ontempchange(inst)
    return inst.components.temperature.current > 50 and -TUNING.DAPPERNESS_LARGE or 0
end

added this into onbecamehuman

inst:ListenForEvent("temperaturedelta", ontempchange)

and added this into master_postinit

inst.components.sanity.custom_rate_fn = ontempchange

And it works. Thanks for the help anyways!

Edited by Navii0

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...