thatsawful Posted April 13, 2016 Share Posted April 13, 2016 Hello! I'm creating my very first simple mod and I got stuck with a really simple thing. All I need is to replace the implementation of Wisecracker:OnUpdate with my own logic. What is the best way to do it in a mod? (I can implement my functionality using AddPlayerPostInit, but it seems to be better to inject my code directly into Wisecracker component). Link to comment https://forums.kleientertainment.com/forums/topic/66320-a-reasonable-way-to-override-a-specific-function/ Share on other sites More sharing options...
Mobbstar Posted April 13, 2016 Share Posted April 13, 2016 (edited) You can manipulate classes using AddClassPostInit (or at least I think that's how it is called). See API Examples for further reference. By the way, consider keeping a reference to the existing function in a local variable and calling that function within your new one. Pseudo-code: local oldfn = self.OnUpdate self:OnUpdate(dt) --code oldfn(self, dt) end Edited April 13, 2016 by Mobbstar corrected pseudo-code Link to comment https://forums.kleientertainment.com/forums/topic/66320-a-reasonable-way-to-override-a-specific-function/#findComment-749698 Share on other sites More sharing options...
thatsawful Posted April 13, 2016 Author Share Posted April 13, 2016 Thank you! Link to comment https://forums.kleientertainment.com/forums/topic/66320-a-reasonable-way-to-override-a-specific-function/#findComment-749702 Share on other sites More sharing options...
Arkathorn Posted April 13, 2016 Share Posted April 13, 2016 Isn't 'Wisecracker' a component? If so, it would probably be better to use 'AddComponentPostInit'. Link to comment https://forums.kleientertainment.com/forums/topic/66320-a-reasonable-way-to-override-a-specific-function/#findComment-749822 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