. . . Posted May 31, 2019 Share Posted May 31, 2019 (edited) Hello, I need help trying to make a code then characters with certain value doesn't get effected by inducedinsanity from purple amulet, skeleton hat, ect. I tried doing this, but it does nothing because my coding skills suck. Spoiler AddComponentPostInit("sanity", function(inst) if not GLOBAL.TheWorld.ismastersim then return end local SetInducedInsanity_old = inst.SetInducedInsanity inst.SetInducedInsanity = function(inst, src, val) if inst.inducedinsanity_immune == true then end return SetInducedInsanity_old(inst, src, val) end end) Thank you for any help and your time have a great day ! Edited June 2, 2019 by Warbucks Link to comment https://forums.kleientertainment.com/forums/topic/106929-solved-help-making-componentpostinit-for-setinducedinsanity-to-make-a-value-prevent-it-from-effecting-prefabs-with-that-value/ Share on other sites More sharing options...
. . . Posted June 1, 2019 Author Share Posted June 1, 2019 bump Link to comment https://forums.kleientertainment.com/forums/topic/106929-solved-help-making-componentpostinit-for-setinducedinsanity-to-make-a-value-prevent-it-from-effecting-prefabs-with-that-value/#findComment-1203513 Share on other sites More sharing options...
YakumoYukari Posted June 2, 2019 Share Posted June 2, 2019 (edited) AddComponentPostInit("sanity", function(self) if not GLOBAL.TheWorld.ismastersim then return end local SetInducedInsanity_old = self.SetInducedInsanity self.SetInducedInsanity = function(self, src, val) if self.inst.inducedinsanity_immune == true then end return SetInducedInsanity_old(self, src, val) end end) The variable scope was wrong Edited June 2, 2019 by YakumoYukari Link to comment https://forums.kleientertainment.com/forums/topic/106929-solved-help-making-componentpostinit-for-setinducedinsanity-to-make-a-value-prevent-it-from-effecting-prefabs-with-that-value/#findComment-1203675 Share on other sites More sharing options...
CarlZalph Posted June 2, 2019 Share Posted June 2, 2019 (edited) Further you should be returning from your callback without calling the old function. AddComponentPostInit( "sanity", function(self) if not GLOBAL.TheWorld.ismastersim then return end local SetInducedInsanity_old = self.SetInducedInsanity self.SetInducedInsanity = function(self, ...) if self.inst.inducedinsanity_immune == true then return somethinghere end return SetInducedInsanity_old(self, ...) end end ) Edited June 2, 2019 by CarlZalph Three shells. Link to comment https://forums.kleientertainment.com/forums/topic/106929-solved-help-making-componentpostinit-for-setinducedinsanity-to-make-a-value-prevent-it-from-effecting-prefabs-with-that-value/#findComment-1203735 Share on other sites More sharing options...
. . . Posted June 2, 2019 Author Share Posted June 2, 2019 (edited) This code seems to work, thanks for all your help guys !! Spoiler AddComponentPostInit("sanity", function(self) if not GLOBAL.TheWorld.ismastersim then return end local SetInducedInsanity_old = self.SetInducedInsanity self.SetInducedInsanity = function(self, ...) if self.inst.inducedinsanity_immune == true then return else return SetInducedInsanity_old(self, ...) end end end) Edited June 2, 2019 by Warbucks Link to comment https://forums.kleientertainment.com/forums/topic/106929-solved-help-making-componentpostinit-for-setinducedinsanity-to-make-a-value-prevent-it-from-effecting-prefabs-with-that-value/#findComment-1203862 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