Saocao Posted October 29, 2018 Share Posted October 29, 2018 Once again I've come seeking aid from this wonderful community. Sadly I lack anything beyond elementary coding skills, and I work on yet another character mod for DST. For my next project I wish to learn how to add an effect that takes place when said character is at low/0 Sanity, such as moving slower/gradually dying. Link to comment Share on other sites More sharing options...
K1NGT1GER609 Posted October 29, 2018 Share Posted October 29, 2018 you could do a periodic task or listen for event for what you want. Periodic task: local function giveitaname(inst) if inst.components.sanity:IsCrazy() then inst.components.locomotor.walkspeed = 2--half normal speed inst.components.locomotor.runspeed = 4 inst.components.health:DoDelta(-1) else inst.components.locomotor.walkspeed = 4--regular speed inst.components.locomotor.runspeed = 6 end end inst:DoPeriodicTask(5, giveitaname, nil, inst)--master_postinit, check every five seconds Listen for event: local function giveitaname(inst) if inst.components.sanity:IsCrazy() then inst.components.locomotor.walkspeed = 2--half normal speed inst.components.locomotor.runspeed = 4 inst.components.health:DoDelta(-1) else inst.components.locomotor.walkspeed = 4--regular speed inst.components.locomotor.runspeed = 6 end end inst:ListenForEvent("sanitydelta", giveitaname)--master_postinit, check everytime the player's sanity goes up or down Both should do the same thing but if for some reason it doesn't work you could replace the if requirement with inst.components.sanity:GetPercent() < 0.2 Link to comment 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