Jump to content

[Solved] Chaining Original Function

Recommended Posts

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)

    local _FindClosestResurrector = self.FindClosestResurrector
    self.FindClosestResurrector = function(self, cause)
        _FindClosestResurrector(self, cause)

    local _DoResurrect = self.DoResurrect
    self.DoResurrect = function(self, res, cause)
        _DoResurrect(self, res, cause)

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

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


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.

  • Create New...