Navii0 Posted September 12, 2020 Share Posted September 12, 2020 (edited) 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 September 12, 2020 by Navii0 Link to comment https://forums.kleientertainment.com/forums/topic/121671-make-player-lose-sanity-when-above-a-certain-temperature/ Share on other sites More sharing options...
penguin0616 Posted September 13, 2020 Share Posted September 13, 2020 Listen for "temperaturedelta" on the player for the temperature. For the sanity loss, take a look at Sanity:AddSanityPenalty and Sanity:RemoveSanityPenalty. 1 Link to comment https://forums.kleientertainment.com/forums/topic/121671-make-player-lose-sanity-when-above-a-certain-temperature/#findComment-1370981 Share on other sites More sharing options...
Navii0 Posted September 13, 2020 Author Share Posted September 13, 2020 (edited) 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 September 13, 2020 by Navii0 Link to comment https://forums.kleientertainment.com/forums/topic/121671-make-player-lose-sanity-when-above-a-certain-temperature/#findComment-1371004 Share on other sites More sharing options...
penguin0616 Posted September 13, 2020 Share Posted September 13, 2020 @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/ 1 Link to comment https://forums.kleientertainment.com/forums/topic/121671-make-player-lose-sanity-when-above-a-certain-temperature/#findComment-1371060 Share on other sites More sharing options...
Navii0 Posted September 14, 2020 Author Share Posted September 14, 2020 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. Link to comment https://forums.kleientertainment.com/forums/topic/121671-make-player-lose-sanity-when-above-a-certain-temperature/#findComment-1371217 Share on other sites More sharing options...
Navii0 Posted September 15, 2020 Author Share Posted September 15, 2020 (edited) 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 September 15, 2020 by Navii0 Link to comment https://forums.kleientertainment.com/forums/topic/121671-make-player-lose-sanity-when-above-a-certain-temperature/#findComment-1371524 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