5E Product Walkthrough Playlist
  1. #1

    Avoiding extension collisions...

    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)

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    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/forum...l=1#post168814
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    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:
    Code:
    -- 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

  4. #4
    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:
    Code:
    -- 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.
    Last edited by Quiverclaw; March 16th, 2015 at 23:16.

  5. #5
    That worked great for data_common.lua thanks!

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

  6. #6
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    Quote Originally Posted by Quiverclaw View Post
    That worked great for data_common.lua thanks!
    Cool. No worries.

    Quote Originally Posted by Quiverclaw View Post
    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:
    Code:
    ...
    <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:

    Code:
    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.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  7. #7
    Sweetness. I think that will work for me!

    I think this actually just got easier!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in