PDA

View Full Version : Can't seem to over-ride function



celestian
October 27th, 2017, 05:13
Okay, so I've been digging into finding out why effects in my ruleset don't expire like they should (such as action effects expiring when it's that characters turn) and I figured out why. It's because I use ascending initiative and CoreRPG uses descending (higher is better there).

Long story short I found the problem in manager_effect.lua, processEffects(). I fixed what I needed and then tried to over ride the other function using these methods.



EffectManager.processEffects = manager_effect_processEffects;
CombatManager.aCustomInitChange = {};
CombatManager.setCustomInitChange(manager_effect_p rocessEffects);


These are in an onInit for my own manager. So, at first I simply tried " EffectManager.processEffects = manager_effect_processEffects;" thinking it would let me use my local copy of the function called "manager_effect_processEffects" but it did not. I then added the "CombatManager.setCustomInitChange(manager_effect_p rocessEffects);" which appeared to work but ... the other one is run also (default one of "CombatManager.setCustomInitChange(processEffects);" so it runs processEffects twice, mine and the broken one. Lastly I thought I could remove the previous by "CombatManager.aCustomInitChange = {};" but that doesn't seem to work either.

So, other than just having a local copy of the CoreRPG manager_effect.lua in my ruleset, is there a way to get around this? I.E. replace the processEffects() function with my own?

edit: Just so im clear, I can replace manager_effect.lua with my own and tag it as "EffectManager" and it works. Just trying to not use such a big hammer.

Bidmaron
October 27th, 2017, 05:41
celestial, is there another extension that might be overriding processEffects? Only the most recently loaded extension would be redirecting that routine.

I am not sure what you mean by:

Lastly I thought I could remove the previous by "CombatManager.aCustomInitChange = {};" but that doesn't seem to work either.

Remove the previous what?

celestian
October 27th, 2017, 05:48
celestial, is there another extension that might be overriding processEffects? Only the most recently loaded extension would be redirecting that routine.

I am not sure what you mean by:


Remove the previous what?

The ruleset has no extensions that do that so shouldn't be an issue as best I can tell.

aCustomInitChange is a table of functions as best I can tell that are run on initiative changing. I was hoping it would flush whatever was there and replace it with mine. I suppose mine could be running before the manager_effect.lua onInit() where that is set as well.

Moon Wizard
October 27th, 2017, 18:11
Since the processEffects is registered within the scope of the EffectsManager script for the unit change event, it will always use it’s own locally scoped version of processEffects.

You could possibly override the onInit function to get around, or just replace the whole script.

Regards,
JPG

celestian
October 27th, 2017, 18:14
Since the processEffects is registered within the scope of the EffectsManager script for the unit change event, it will always use it’s own locally scoped version of processEffects.

You could possibly override the onInit function to get around, or just replace the whole script.


Might be best to replace the onInit() in this case that way I don't have to replace the entire script. I really want to try and avoid having to revisit all this code everytime things change to make sure im current ;)

I'll give that a shot. Thanks!

celestian
November 1st, 2017, 18:02
I ended up not getting the over-ride to work for onInit() and had to replace the file itself. Could be I just need to spend a little more time on it to sort out the reason but I'm plodding through a build of a AD&D ref-manual for myself and it's draining my will to live.

Myrdin Potter
November 2nd, 2017, 00:28
Every time I try and make a ref manual, my will to Love gets drained to. I suspect a rogue function in the code somewhere ...

Varsuuk
November 3rd, 2017, 06:30
I ended up not getting the over-ride to work for onInit() and had to replace the file itself. Could be I just need to spend a little more time on it to sort out the reason but I'm plodding through a build of a AD&D ref-manual for myself and it's draining my will to live.

Ugh :( I can only imagine ...

Varsuuk
November 3rd, 2017, 06:31
I wish so much WotC made this so we could just PAY for AD&D mods ;P

celestian
November 3rd, 2017, 16:14
Ugh :( I can only imagine ...

I've got PHB and DMG both done (tho I'll probably keep fiddling with the magic tables in DMG). They turned out really nice and the search filters I worked on for the DMG seem to be working out very well. Don't have images in them because... well I don't need them but the text is directly from the CoreRules CD import so tables/formatting is all very good.

If they ever wanna start allowing support of AD&D it'd be a good starting point for them. (WoTC).