GRNNOperator Posted September 16, 2023 Share Posted September 16, 2023 I plan to have a character who loses hunger when working but gains sanity when working. This is what I tried and it didn't work. (all of the hunger stuff works fine, just the sanity part doesn't work) local function OnWork(inst, data) local burnrate = inst.components.hunger.burnratemodifiers:Get() if data.action.action == ACTIONS.CHOP or data.action.action == ACTIONS.MINE or data.action.action == ACTIONS.PICK or data.action.action == ACTIONS.HAMMER or data.action.action == ACTIONS.DIG or data.action.action == ACTIONS.TILL then if inst._cdtask == nil then inst._cdtask = inst:DoTaskInTime(0.3, OnCooldown) inst.components.hunger:DoDelta(-1 * burnrate, true) inst.components.sanity:DoDelta(1) end end end Link to comment https://forums.kleientertainment.com/forums/topic/150991-how-do-i-make-a-character-gain-sanity-when-working/ Share on other sites More sharing options...
Hamurlik Posted September 18, 2023 Share Posted September 18, 2023 This code works fine for me. You must be testing a wrong version of the mod, before you added this change. Maybe you forgot to save the file? Link to comment https://forums.kleientertainment.com/forums/topic/150991-how-do-i-make-a-character-gain-sanity-when-working/#findComment-1665517 Share on other sites More sharing options...
GRNNOperator Posted September 22, 2023 Author Share Posted September 22, 2023 That's true actually, I don't know why it didn't work before, but thank you for your help! Link to comment https://forums.kleientertainment.com/forums/topic/150991-how-do-i-make-a-character-gain-sanity-when-working/#findComment-1666255 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