-
November 21st, 2020, 15:33 #1
- Join Date
- Jan 2020
- Posts
- 222
Add to a class' onInit() - replace / merge?
If I want to add functionality to the end of a class' onInit() function, do I have to completely replace the onInit() and add my code to the end?
Is there any way to effectively merge it? That is to say, have the original onInit() run, then have my additional function run right afterwards?
Thanks.
-
November 21st, 2020, 16:17 #2
This might at least get you going in the right direction:
Code:function onInit() -- ensure the CoreRPG scripts load if super and super.onInit then super.onInit() end -- new code goes here end
-
November 21st, 2020, 16:30 #3
- Join Date
- Jan 2020
- Posts
- 222
-
November 21st, 2020, 17:13 #4
- Join Date
- Jan 2020
- Posts
- 222
Now let's say that script, the one with the original onInit() has a local variable declared at the top of the script like so:
Code:local nSomeVariable;
-
November 21st, 2020, 20:09 #5
No clue, I'm too new at the Lua side of things to have a grip on how the layering works, but my (extremely limited) understanding is that local variables/tables only exist within the functions they're defined in. If you go poking around the CoreRPG + ruleset scripts you'll find a lot of similar things being defined in each script so I'm guessing it'd be easier to just replicate the one you're wanting in your own function to make sure you're getting the correct value.
-
November 21st, 2020, 22:45 #6
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks