. . . Posted June 9, 2016 Share Posted June 9, 2016 (edited) Hello, I need help trying to make a keyhandler action crash free... Okay, the crash is in the image... Now here's the code local STEALTH = GLOBAL.Action() STEALTH.str = "Stealth" STEALTH.id = "STEALTH" STEALTH.fn = function(act) if act.target.components.sanity.current >= 46 and act.target.components.sanity:IsSane() and act.target.components.sheltered.sheltered and act.target.hide_cooldown == nil then act.target.hide_cooldown = true act.target:DoTaskInTime(10, function() act.target.hide_cooldown = nil end) act.target:DoTaskInTime(0.05, function() act.target.components.grogginess:SetDecayRate(0) act.target.AnimState:SetMultColour(.95,.95,.95,.95) act.target.components.grogginess:AddGrogginess(0.25) end) act.target:DoTaskInTime(0.10, function() act.target.AnimState:SetMultColour(.90,.90,.90,.90) end) act.target:DoTaskInTime(0.15, function() act.target.AnimState:SetMultColour(.85,.85,.85,.85) end) act.target:DoTaskInTime(0.20, function() act.target.AnimState:SetMultColour(.80,.80,.80,.80) end) act.target:DoTaskInTime(0.25, function() act.target.AnimState:SetMultColour(.75,.75,.75,.75) end) act.target:DoTaskInTime(0.30, function() act.target.AnimState:SetMultColour(.70,.70,.70,.70) end) act.target:DoTaskInTime(0.35, function() act.target.AnimState:SetMultColour(.65,.65,.65,.65) end) act.target:DoTaskInTime(0.40, function() act.target.AnimState:SetMultColour(.60,.60,.60,.60) end) act.target:DoTaskInTime(0.45, function() act.target.AnimState:SetMultColour(.55,.55,.55,.55) end) act.target:DoTaskInTime(0.50, function() act.target.AnimState:SetMultColour(.50,.50,.50,.50) end) act.target:DoTaskInTime(0.55, function() act.target.AnimState:SetMultColour(.45,.45,.45,.45) end) act.target:DoTaskInTime(0.60, function() act.target.AnimState:SetMultColour(.40,.40,.40,.40) end) act.target:DoTaskInTime(0.65, function() act.target.AnimState:SetMultColour(.35,.35,.35,.35) end) act.target:DoTaskInTime(0.70, function() act.target.AnimState:SetMultColour(.30,.30,.30,.30) end) act.target:DoTaskInTime(0.75, function() act.target.AnimState:SetMultColour(.25,.25,.25,.25) end) act.target:DoTaskInTime(0.80, function() act.target.AnimState:SetMultColour(.20,.20,.20,.20) end) act.target:DoTaskInTime(0.85, function() act.target.AnimState:SetMultColour(.15,.15,.15,.15) end) act.target:DoTaskInTime(0.90, function() act.target.AnimState:SetMultColour(.10,.10,.10,.10) end) act.target:DoTaskInTime(0.95, function() act.target:AddTag("notarget") act.target.components.hunger:DoDelta(-25) act.target.AnimState:SetMultColour(.05,.05,.05,.05) act.target.components.talker:Say("Dirka, dirka shabala!") end) act.target:DoTaskInTime(10, function() -- The crash is happening from here, I need someone to help me act.target:RemoveTag("notarget") -- Make this TaskInTime not trigger if the character's dead or a ghost... act.target.DynamicShadow:Enable(true) act.target.AnimState:SetMultColour(1.0,1.0,1.0,1.0) act.target.components.grogginess.wearoffduration = 0.01 act.target.components.grogginess.knockoutduration = 0 act.target.components.grogginess.grog_amount = 0 act.target.components.grogginess.wearofftime = 0 end) elseif act.target.components.sanity.current >= 46 and act.target.components.sanity:IsSane() and not act.target.components.sheltered.sheltered then act.target.components.talker:Say("I can't hide without cover!") elseif act.target.components.sanity.current >= 46 and not act.target.components.sanity:IsSane() and act.target.components.sheltered.sheltered then act.target:RemoveTag("notarget") act.target.DynamicShadow:Enable(true) act.target.AnimState:SetMultColour(1.0,1.0,1.0,1.0) act.target.components.talker:Say("OnLy WeAkLiNgS hIdE!!!") act.target.components.grogginess.wearoffduration = 0.01 act.target.components.grogginess.knockoutduration = 0 act.target.components.grogginess.grog_amount = 0 act.target.components.grogginess.wearofftime = 0 elseif act.target.components.sanity.current >= 46 and not act.target.components.sanity:IsSane() and not act.target.components.sheltered.sheltered then act.target:RemoveTag("notarget") act.target.DynamicShadow:Enable(true) act.target.AnimState:SetMultColour(1.0,1.0,1.0,1.0) act.target.components.talker:Say("OnLy WeAkLiNgS hIdE!!!") act.target.components.grogginess.wearoffduration = 0.01 act.target.components.grogginess.knockoutduration = 0 act.target.components.grogginess.grog_amount = 0 act.target.components.grogginess.wearofftime = 0 elseif act.target.components.sanity.current <= 45.99 and act.target.components.sheltered.sheltered then act.target:RemoveTag("notarget") act.target.DynamicShadow:Enable(true) act.target.AnimState:SetMultColour(1.0,1.0,1.0,1.0) act.target.components.talker:Say("OnLy WeAkLiNgS hIdE!!!") act.target.components.grogginess.wearoffduration = 0.01 act.target.components.grogginess.knockoutduration = 0 act.target.components.grogginess.grog_amount = 0 act.target.components.grogginess.wearofftime = 0 elseif act.target.components.sanity.current <= 45.99 and not act.target.components.sheltered.sheltered then act.target:RemoveTag("notarget") act.target.DynamicShadow:Enable(true) act.target.AnimState:SetMultColour(1.0,1.0,1.0,1.0) act.target.components.talker:Say("OnLy WeAkLiNgS hIdE!!!") act.target.components.grogginess.wearoffduration = 0.01 act.target.components.grogginess.knockoutduration = 0 act.target.components.grogginess.grog_amount = 0 act.target.components.grogginess.wearofftime = 0 end end AddAction(STEALTH) This is the code causing the crash act.target:DoTaskInTime(10, function() act.target:RemoveTag("notarget") act.target.DynamicShadow:Enable(true) act.target.AnimState:SetMultColour(1.0,1.0,1.0,1.0) act.target.components.grogginess.wearoffduration = 0.01 act.target.components.grogginess.knockoutduration = 0 act.target.components.grogginess.grog_amount = 0 act.target.components.grogginess.wearofftime = 0 end) It causes a crash while i'm in my stealth action if I die before it ended this crash happens because this DoTaskInTime's trying to remove something that doesn't exist... I need someone's help to make it not activate if the player's a ghost or dead, I tried doing stuff like... elseif not act.target:HasTag("playerghost") or not act.target.components.health:IsDead() or not act.target.components.health.currenthealth <= 0.01 then act.target:DoTaskInTime(10, function() act.target:RemoveTag("notarget") act.target.DynamicShadow:Enable(true) act.target.AnimState:SetMultColour(1.0,1.0,1.0,1.0) act.target.components.grogginess.wearoffduration = 0.01 act.target.components.grogginess.knockoutduration = 0 act.target.components.grogginess.grog_amount = 0 act.target.components.grogginess.wearofftime = 0 end) but when I put those stuff it either makes the other bottom half of the action never activate or nothing happens... I really could use some help, i'm starting to give up on trying to fix this. Edited June 9, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/68042-need-help-fixing-keyhandler-action/ Share on other sites More sharing options...
Aquaterion Posted June 9, 2016 Share Posted June 9, 2016 (edited) To reduce some code change this(the whole block): act.target:DoTaskInTime(0.10, function() act.target.AnimState:SetMultColour(.90,.90,.90,.90) ...... act.target.AnimState:SetMultColour(.10,.10,.10,.10) end) to this: local val = .95 act.target.colortask = act.target:DoPeriodicTask(0.05, function() val = val - .05 act.target.AnimState:SetMultColour(val,val,val,val) if val <= 0.1 then act.target.colortask:Cancel() end end) -- as for the crashing, try changing this: act.target:DoTaskInTime(10, function() -- The crash is happening from here, I need someone to help me act.target:RemoveTag("notarget") -- Make this TaskInTime not trigger if the characters dead or a ghost... act.target.DynamicShadow:Enable(true) act.target.AnimState:SetMultColour(1.0,1.0,1.0,1.0) act.target.components.grogginess.wearoffduration = 0.01 act.target.components.grogginess.knockoutduration = 0 act.target.components.grogginess.grog_amount = 0 act.target.components.grogginess.wearofftime = 0 end) --to act.target:DoTaskInTime(10, function() act.target:RemoveTag("notarget") act.target.DynamicShadow:Enable(true) act.target.AnimState:SetMultColour(1.0,1.0,1.0,1.0) if act.target:HasTag("playerghost") then return end act.target.components.grogginess.wearoffduration = 0.01 act.target.components.grogginess.knockoutduration = 0 act.target.components.grogginess.grog_amount = 0 act.target.components.grogginess.wearofftime = 0 end) Edited June 9, 2016 by Aquaterion Link to comment https://forums.kleientertainment.com/forums/topic/68042-need-help-fixing-keyhandler-action/#findComment-781609 Share on other sites More sharing options...
. . . Posted June 9, 2016 Author Share Posted June 9, 2016 Thank you so much Aquaterion it doesn't crash anymore !!!!!!!! Link to comment https://forums.kleientertainment.com/forums/topic/68042-need-help-fixing-keyhandler-action/#findComment-781629 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