DICE PACKS BUNDLE
  1. #1

    Extension Question

    Hi. I have built a basic extension that replaces the 3.5 skills with the PF ones and modifies them a bit. It also uses the rank system of PF. I'm really a newbie so I've basically hacked my way into an extension by using the awesome help I got from Trenloe on my last thread and combining it with bits from existing extensions.

    My question is, is it possible to override only certain parts of the code inside a lua or xml file instead of replacing the whole file itself? For instance, when I'm adding custom skills I'm only editing a certain paragraph inside the data_common.lua file. Is it somehow possible to only override the necessary code while leaving the rest of the original ruleset file intact? I hope that makes any sense as I really don't have any experience in lua etc.

    Thanks in advance!

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    Depending on where the code is, you can override the whole function/table with new code - but it has to be the whole function or table. You can override functions/tables in global scripts - scripts that are initialised using the <script> tag in the <root> of an XML file - i.e. not being assigned to a control or windowclass element. An example of these global scripts are the <script> entries at the end of the base.xml file in the 3.5E ruleset.

    If you want to override a script then you'll need to have something like this in your extension LUA. This will override DataCommon.isPFRPG with your new function - this is just an example:

    Code:
    function onInit()
    	DataCommon.isPFRPG = myNewFunction
    end
    
    function myNewFunction()
    	...code
    	...code
    	...code
    end
    If you want to completely override a table in a global script, do something similar:

    Code:
    function onInit()
    	DataCommon.abilities = newAbilities
    end
    
    newAbilities = {
    	"strength",
    	"dexterity",
    	"constitution",
    	"intelligence",
    	"wisdom",
    	"charisma"
    };
    Put the above code in a global LUA package (file) within your extension.

    For XML you can override the XML specification for a specific element attached to the <root> level of an XML file - these are usually framesdefs, windowclasses, templates, etc.. Just have the complete override XML in your extension and <include> that XML file to initialise it.

    You can also get a bit more creative and use merge tags, but we'll save that for another lesson.

    Note/Warning: Whereas the above will reduce the amount of code in your extension and make it a bit more future proof, it can make it difficult to review your extension for needed updates when a future FG version is released.

    Basing your code off complete LUA and XML files allows you to include the original file you used in your extension for reference purposes and then do a compare with a future version of these files. If they are the same then you don't need to update, if they are different then you can incorporate the new version changes into your extension code (usually by copy/pasting your extension code into the new version of the relevant file/s). See this extension as an example of me including the original files - and naming them with the original ruleset and version: https://www.fantasygrounds.com/forum...-on-CoreRPG%29

    Overriding functions and XML means you can't do whole file comparisons, you'll need to either stare-and-compare or do comparisons on individual tables/function/XML elements - once you find which file they are in.
    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
    Fantastic. Took me a while to get it right but I've managed to sort everything out! Thanks a lot for your help I just have one issue and that doesn't really seem to be about the extension. The cross-class-double-cost thing won't come back even if I disable my extension and go with the standard 3.5E set (restoring the original updateSkillPoints function in manager_char.lua). Any ideas?

    Your note about being able to do whole file comparisons makes sense too. But this way just goes better with my OCD :P

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    Quote Originally Posted by rhuobhe View Post
    The cross-class-double-cost thing won't come back even if I disable my extension and go with the standard 3.5E set (restoring the original updateSkillPoints function in manager_char.lua). Any ideas?
    It only gets triggered when a rank is changed - make a change to one of the skill ranks and see if it calculates it correctly.
    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!

  5. #5
    Quote Originally Posted by Trenloe View Post
    It only gets triggered when a rank is changed - make a change to one of the skill ranks and see if it calculates it correctly.
    Yup, tried that but it just won't double the cost no matter what. Actually, it was doubling the cost even though I have enabled my extension before so I've tried editing the ruleset which worked. But after that I have restored the original ruleset but the PF behaviour stayed (with or without extension)

    Perhaps I have screwed up something else.

  6. #6
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    Quote Originally Posted by rhuobhe View Post
    Perhaps I have screwed up something else.
    Looks that way.

    Try it in a new 3.5e campaign and see if it works. This will give you an idea if it is the data in the old campaign that is causing the issue or if it is still the underlying code.
    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
    Quote Originally Posted by Trenloe View Post
    Looks that way.

    Try it in a new 3.5e campaign and see if it works. This will give you an idea if it is the data in the old campaign that is causing the issue or if it is still the underlying code.
    Will certainly do Thanks a lot again for the great support!

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
  •  
FG Spreadshirt Swag

Log in

Log in