PDA

View Full Version : Avoiding extension collisions...



Quiverclaw
March 16th, 2015, 19:52
So I'm working on my first mod and I pretty well have it functioning like I want it to. However, because it overrides what I believe are some pretty major pieces of the ruleset, I'm worried about it being incompatible with other extensions. I'm pretty new to FantasyGrounds so I'm not sure how this should best be handled.

For instance, my mod modifies the scripts/data_common.lua. I imagine that this is a fairly common piece of lua to overwrite so my concern is how I keep my modification from conflicting with others.

Is there are a clean way to do this? A way were I insert only the change code in my new data_common.lua instead of completely replacing it?

(for what it's worth, I've added a 7th attribute to 3.5E and updated all the character sheets and scripts to go with it)

Trenloe
March 16th, 2015, 20:58
See this post for some examples of how to add to the LUA tables in data_common.lua without changing the base file: https://www.fantasygrounds.com/forums/showthread.php?20505-Alignment-Condition-extension&p=168814&viewfull=1#post168814

Quiverclaw
March 16th, 2015, 21:27
I saw that thread, and it was helpful but you appeared to be adding completely new functionality. I'm talking about modifying the way existing functions work, such as, from data_common.lua:


-- Abilities (database names)
abilities = {
"strength",
"dexterity",
"constitution",
"intelligence",
"wisdom",
-- Mod by QC for Comeliness Attribute Support
-- added ,
"charisma",
-- added entire line
"comeliness"
-- End QC Mod
};
If I put that in a stand-alone lua, would it be available to campaign/record_char_main.xml and override the existing data_common.lua function of the same name?

Sorry if I'm being dense. I'm new to LUA/XML and FantasyGrounds. :)

Though I do have a my extension fully functional atm so I'm pretty happy about that!

https://game.tall-tales-racing.com/ADnD/sample.jpg

Quiverclaw
March 16th, 2015, 23:12
Hmm, looks like something ate my reply. In short, I looked at that once before... That seemed to be for a new function. I'm adjusting existing functions like:


-- Abilities (database names)
abilities = {
"strength",
"dexterity",
"constitution",
"intelligence",
"wisdom",
-- Mod by QC for Comeliness Attribute Support
"charisma",
"comeliness"
-- End QC Mod
};


Will the sample code still work? I got the impression it wouldn't. If I list the whole function in a separate LUA will it override the data_common.lua?

OR

*edit* I could just be dumb. :) I'm going to try it now that I've re-re-re-re-read it.

Quiverclaw
March 16th, 2015, 23:31
That worked great for data_common.lua thanks!

Any equivalent for replacing entire functions from the manager_actor2.lua and manager_ps2.lua?

Trenloe
March 17th, 2015, 01:07
That worked great for data_common.lua thanks!
Cool. No worries.


Any equivalent for replacing entire functions from the manager_actor2.lua and manager_ps2.lua?
As long as the script is a global script package they you can override it - i.e. it is defined in the ruleset base.xml using a <script> parameter, so it is "global" to the whole ruleset.

Both of these scripts are defined in the ruleset base.xml:

...
<script name="PartyManager2" file="ps/scripts/manager_ps2.lua" />
...
<script name="ActorManager2" file="scripts/manager_actor2.lua" />
...
These both have global references of PartyManager2 and ActorManager2 respectively. You can override individual functions within these global packages by referring to it as <Global package>.<Function name> and overriding that function.

If you're using the 3.5e ruleset, you could override the getPercentWounded function in manager_actor2.lua with:


Function onInit()
ActorManager2.getPercentWounded = myGetPercentWounded;
end

function myGetPercentWounded(sNodeType, node)
...
My custom code to replace this function.
...
end

Have the above code in a global script package in your extension so that it will execute when the extension loads, run the onInit function and override the base ActorManager2.getPercentWounded with your custom function myGetPercentWounded.

You can only do this in global script packages, you can't do this for LUA attached directly to a control.

Quiverclaw
March 17th, 2015, 01:58
Sweetness. I think that will work for me!

I think this actually just got easier! :) :) :)