PDA

View Full Version : referencing local variables (or not) in CoreRPG



Stv
January 19th, 2021, 19:04
Hi Guys, I just want to make sure I have this right, before I look down a different path.

in CoreRPG EffectManager, there is the following function



local fCustomOnEffectStartTurn = nil;
function setCustomOnEffectStartTurn(f)
fCustomOnEffectStartTurn = f;
end


If I have this right, if I call the setCustomOnEffectStartTurn(f) function with a reference to my new function then there is no way to be able to call an existing
fCustomOnEffectStartTurn as mine will overwrite any previously set function?

Cheers, Steve.

Trenloe
January 19th, 2021, 19:19
If I have this right, if I call the setCustomOnEffectStartTurn(f) function with a reference to my new function then there is no way to be able to call an existing
fCustomOnEffectStartTurn as mine will overwrite any previously set function?
Correct. As fCustomOnEffectStartTurn is a variable local to the EffectsManager global script package, you can't access it from outside - so you can't make a copy of the previous script. The only vague option you may have is if you know where that override is set (i.e. it's in a ruleset layered on top of CoreRPG) and you can access that override function. But that won't help much if other extensions are changing it in different ways.

Stv
January 19th, 2021, 19:31
That's what I thought :(
I was hoping I could reference any previous to aid in cross-extension campatibility, guess it's 'last on to use it wins' :D

I may well look down a different path to do what I want.

As ever, thanks for the input Trenloe.

Cheers, Steve.