zetake Posted June 21, 2021 Share Posted June 21, 2021 (edited) How do you currently chain original function? Because this: AddComponentPostInit("resurrectable", function(self, inst) local _CanResurrect = self.CanResurrect self.CanResurrect = function(self, cause) _CanResurrect(self, cause) end local _FindClosestResurrector = self.FindClosestResurrector self.FindClosestResurrector = function(self, cause) _FindClosestResurrector(self, cause) end local _DoResurrect = self.DoResurrect self.DoResurrect = function(self, res, cause) _DoResurrect(self, res, cause) end end) Doesn't work for me. I've tried AddComponentPostInit and AddClassPostConstruct. And modifications do works, but they doesn't chain original functions. So my mod is worthless in this case. Edited June 23, 2021 by zetake Link to comment https://forums.kleientertainment.com/forums/topic/131037-solved-chaining-original-function/ Share on other sites More sharing options...
CarlZalph Posted June 21, 2021 Share Posted June 21, 2021 It's missing the handling of return parameters. I wrote a thing a little bit back showing the boilerplate for function hooking here: 1 1 Link to comment https://forums.kleientertainment.com/forums/topic/131037-solved-chaining-original-function/#findComment-1471036 Share on other sites More sharing options...
zetake Posted June 21, 2021 Author Share Posted June 21, 2021 (edited) So I didn't return value returned by original function. Thanks, now it works. Ah, I see. If a function has a return, you not only have to call original function, but you also have to return value returned by that original function or post edited value of it. Because original function is meant to return value to wherever it was called from, but after modification it return value to your modified function instead, and your modified function doesn't pass it on, by default. So, if you don't return it like me, it will fail for you also. Edited June 23, 2021 by zetake 1 Link to comment https://forums.kleientertainment.com/forums/topic/131037-solved-chaining-original-function/#findComment-1471069 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