Tideturner
October 13th, 2017, 14:11
Hi,
Axoid alerted me to the fact that my extension, NPC flavors (https://www.fantasygrounds.com/forums/showthread.php?31699-Alternative-to-NPC-numbering-in-combat-tracker), conflicts with the Advanced Effects (https://www.fantasygrounds.com/forums/showthread.php?40270-Item-Enhancement-(add-effects-to-items-and-when-they-are-equipped-apply-them)) extension by celestian.
I took a look at it and both extensions make use of the CombatManager.setCustomAddNPC(addNPC) functionality. As far as I can see, there is not really any way for me to resolve this conflict as it is now.
It could however be resolved by introducing method chaining (if that's the correct term) on CoreRPG CombatManager.setCustomAddNPC
Change CorePG/scripts/manager_combat.lua FROM
local fCustomAddNPC = nil;
function setCustomAddNPC(fAddNPC)
fCustomAddNPC = fAddNPC;
end
To:
local fCustomAddNPC = nil;
function setCustomAddNPC(fAddNPC)
fCustomAddNPCChain = fCustomAddNPC;
fCustomAddNPC = fAddNPC;
return fCustomAddNPCChain;
end
That way extensions making use of the setCustomAddNPC could change their code from:
function onInit()
CombatManager.setCustomAddNPC(addNPC);
end
function addNPC(sClass, nodeNPC, sName)
local nodeEntry;
if CombatManager2.addNPC then
nodeEntry = CombatManager2.addNPC(sClass, nodeNPC, sName);
else
nodeEntry = CombatManager.addNPCHelper(nodeNPC, sName);
end;
-- Whatever the extension does after running the ruleset addNPC
end
To something like:
local addNPCChain = nil;
function onInit()
addNPCChain = CombatManager.setCustomAddNPC(addNPC);
end
function addNPC(sClass, nodeNPC, sName)
local nodeEntry;
if addNPCChain then
nodeEntry = addNPCChain(sClass, nodeNPC, sName);
else
nodeEntry = CombatManager.addNPCHelper(nodeNPC, sName);
end;
-- Whatever the extension does after running the ruleset addNPC
end
So the addNPC functionality would execute something like this:
Extension 1 > Extension 2 > 5E > CoreRPG
This would also require the 5E ruleset to add the setCustomAddNPC chain I think. And, as far as I'm able to wrap my mind around it, it shouldn't break any other rulesets.
Perhaps someone cleverer than me can have a think on this to see if it's even possible, or if it's considered a bad idea or some such.
Thanks for reading :)
Tideturner.
Axoid alerted me to the fact that my extension, NPC flavors (https://www.fantasygrounds.com/forums/showthread.php?31699-Alternative-to-NPC-numbering-in-combat-tracker), conflicts with the Advanced Effects (https://www.fantasygrounds.com/forums/showthread.php?40270-Item-Enhancement-(add-effects-to-items-and-when-they-are-equipped-apply-them)) extension by celestian.
I took a look at it and both extensions make use of the CombatManager.setCustomAddNPC(addNPC) functionality. As far as I can see, there is not really any way for me to resolve this conflict as it is now.
It could however be resolved by introducing method chaining (if that's the correct term) on CoreRPG CombatManager.setCustomAddNPC
Change CorePG/scripts/manager_combat.lua FROM
local fCustomAddNPC = nil;
function setCustomAddNPC(fAddNPC)
fCustomAddNPC = fAddNPC;
end
To:
local fCustomAddNPC = nil;
function setCustomAddNPC(fAddNPC)
fCustomAddNPCChain = fCustomAddNPC;
fCustomAddNPC = fAddNPC;
return fCustomAddNPCChain;
end
That way extensions making use of the setCustomAddNPC could change their code from:
function onInit()
CombatManager.setCustomAddNPC(addNPC);
end
function addNPC(sClass, nodeNPC, sName)
local nodeEntry;
if CombatManager2.addNPC then
nodeEntry = CombatManager2.addNPC(sClass, nodeNPC, sName);
else
nodeEntry = CombatManager.addNPCHelper(nodeNPC, sName);
end;
-- Whatever the extension does after running the ruleset addNPC
end
To something like:
local addNPCChain = nil;
function onInit()
addNPCChain = CombatManager.setCustomAddNPC(addNPC);
end
function addNPC(sClass, nodeNPC, sName)
local nodeEntry;
if addNPCChain then
nodeEntry = addNPCChain(sClass, nodeNPC, sName);
else
nodeEntry = CombatManager.addNPCHelper(nodeNPC, sName);
end;
-- Whatever the extension does after running the ruleset addNPC
end
So the addNPC functionality would execute something like this:
Extension 1 > Extension 2 > 5E > CoreRPG
This would also require the 5E ruleset to add the setCustomAddNPC chain I think. And, as far as I'm able to wrap my mind around it, it shouldn't break any other rulesets.
Perhaps someone cleverer than me can have a think on this to see if it's even possible, or if it's considered a bad idea or some such.
Thanks for reading :)
Tideturner.