PDA

View Full Version : Advice on how to package change to CoreRPG.pak lua file into an extension



secors
May 31st, 2024, 23:11
Hi all,

I have been working on some great advice from Trenloe on building a 'fairly' simple change to how effects are presented in the combat tracker.
Basically, Trenloe created a great extension to sort the combat tracker effects windowlist alphabetically and I would like to add a corresponding change to the pipe delimited list of unexpanded effects. I have the code change to be implemented but it is in manager_effect.lua in CoreRPG.pak (it is a one liner even).

How do I go about packaging a change to manager_effect.lua into an extension so that the method affected can be applied to any ruleset without being overwritten should that package get changed by the powers that be? How does one keep up with any changes to the base pak file so that higher level changes can be absorbed? Is there a way to specify changes in an extension at the method level? How does the community monitor changes to core functionality that would supersede custom changes?

Secondly, is it advisable to make the change an option and if so, how would that be performed (my change is in function manager_effect.lua(getEffectsString()))?

Many thanks to all for educating me on these processes!!!


Cheers!

damned
June 1st, 2024, 01:54
Sometimes you have to replace the whole script or the whole function. Other times you can use super to modify a much smaller amount.

Moon Wizard
June 1st, 2024, 02:38
For global scripts, as an example to replace EffectsManager.getEffectsString function; you could write an extension with a tag like this:



<script name="EffectManagerMyOverride">
function onInit()
EffectManager.getEffectsString = getEffectsString;
end
function getEffectsString(nodeCTEntry, bPublicOnly)
... your code here ...
end
</script>


and if you wanted to call the original first, you could do:


<script name="EffectManagerMyOverride">
local _fnOrigGetEffectsString;
function onInit()
_fnOrigGetEffectsString = EffectManager.getEffectsString;
EffectManager.getEffectsString = getEffectsString;
end
function getEffectsString(nodeCTEntry, bPublicOnly)
local sResult = _fnOrigGetEffectsString(nodeCTEntry, bPublicOnly);
... your code here ...
return sResult;
end
</script>


Window/control script overrides work differently, where you can layer on top of the existing functions. The thing to remember in this case is that function calls must be called from the object to make sure it grabs the highest layer and not the local layer. (i.e. calls within global scripts between functions; calls in lower level scripts you want to override; etc.) If you're looking at that, more info can be had.

Regards,
JPG

secors
June 1st, 2024, 06:04
Thanks JPG. Great example.

Based on that work, I was able to extend the functionality to both the expanded effects list [from Trenloe] and the collapsed effects string in the combat tracker [refactoring getEffectsString].
There is a small disconnect between the two sets when ordering strings that are identical in all but [letter] case.

secors
June 5th, 2024, 00:30
Please let me know what you think!
Cheers

Morenu
June 5th, 2024, 03:17
Psst.. I think you should put it on forge

secors
June 5th, 2024, 14:05
Thanks. Will do!