hqz Posted July 29, 2021 Share Posted July 29, 2021 Is there a way to somehow "inject" a new function implementation? A bit like Harmony in other games. Basically I just want to override CaptainGenerator.calculateSalary() but I don't want to have to copy the whole script just for this. Link to comment Share on other sites More sharing options...
FuryoftheStars Posted August 9, 2021 Share Posted August 9, 2021 (edited) local oldCaptainGenerator_calculateSalary = CaptainGenerator.calculateSalary function CaptainGenerator.calculateSalary() oldCaptainGenerator_calculateSalary() — new code here end In a nut shell. If this function returns anything, then you also need to make sure to capture what it returns, like this: local oldCaptainGenerator_calculateSalary = CaptainGenerator.calculateSalary function CaptainGenerator.calculateSalary() local returnvalue = oldCaptainGenerator_calculateSalary() — new code here return returnvalue end And of course, if the function has parameters, make sure you’re passing those along, too. You should probably hop on the discord, though. Seems like most people hang out there rather than the forums now a days. 😕 Edited August 9, 2021 by FuryoftheStars 1 Link to comment Share on other sites More sharing options...
hqz Posted August 9, 2021 Author Share Posted August 9, 2021 Thanks. This is really helpful. I didn't realize that I could just override any function by defining a new one with the same name and the same namespace. This opens a lot of interesting opportunities. Link to comment 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