-
December 13th, 2019, 20:02 #1
Calling the original function in an overridden function.
I'm trying to figure out how to call an original function later in the code, that has been overriden/redirected in the onInit() function.
The onInit looks as follows:
Code:function onInit() EffectManager.addEffect = addEffectDuplicateCheck; end
Such as in addEffectDuplicateCheck:
Code:if (bFoundDuplicate == false) then EffectManager.addEffect = EffectManager.addEffect; -- attempt at redirecting function back to its original EffectManager.addEffect(sUser, sIdentity, nodeCT, rNewEffect, bShowMsg); end
Currently this functionality will put FG into and endless loop, as the function is calling itself continually.
Is there a way to do this?
I'd rather not copy the about 90 lines of code from the original EffectsManager.addEffect function, and rewrite it to work in the new .lua.
As that would be rather messy coding and harder to maintain.Last edited by StoryWeaver; December 13th, 2019 at 20:09.
Extension writer, FGU Backer, Ultimate License holder.
5E Enhancer (development and support on hold for now)
Combat Enhancer 5E Classic (no longer officially supported, community support only)
ps. Do not send PM's for support for the extensions I write, I will not not be able to respond there. Use the relevant forum threads instead so the community can benefit from the replies, thank you.
-
December 13th, 2019, 20:57 #2
If you override a function in a global script package then you've overridden it. I don't believe the "super" reference for layered scripts works with global packages.
But, the EffectManager.addEffect function has two custom function calls already built in: fCustomOnEffectAddStart and fCustomOnEffectAddEnd which are specifically there to allow developers to tie in code into that function without having to modify the base function itself. You can set the code for these functions through EffectManager.setCustomOnEffectAddStart(f) and EffectManager.fCustomOnEffectAddEnd(f) where f is a function within your custom code. You'll need to look at the EffectManager.addEffect to see where these run and what you can do with these custom functions.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
December 14th, 2019, 00:21 #3
- Join Date
- Jun 2013
- Location
- Isanti, MN
- Posts
- 2,922
-
December 14th, 2019, 01:14 #4
Thank you Andraax, that worked!
I had tried something similar as a global constant, which didn't work. Putting it in the onInit() function however saved the original function into memory correctly.Extension writer, FGU Backer, Ultimate License holder.
5E Enhancer (development and support on hold for now)
Combat Enhancer 5E Classic (no longer officially supported, community support only)
ps. Do not send PM's for support for the extensions I write, I will not not be able to respond there. Use the relevant forum threads instead so the community can benefit from the replies, thank you.
-
December 14th, 2019, 08:54 #5
Sorry, I misunderstood what you were trying to do. Glad Andraax sorted you out! :-)
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks