zetake Posted June 21, 2021 Share Posted June 21, 2021 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. Link to comment 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: Link to comment Share on other sites More sharing options...
zetake Posted June 21, 2021 Author Share Posted June 21, 2021 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.