FG Spreadshirt Swag
  1. #1

    Modifying 5e automated rules (using long rest healing as an example)

    I am very new to FantasyGrounds (joined with the kickstarter for Unity), and I'm trying to learn as much as I can about the program and how I can modify its automated processes for use with my homebrew rules for a 5e campaign. I figured a reasonably easy yet maybe complicated thing to start with would be to modify the long and short rest healing rules to match the way I've been running my game. The Basic Extension Coding Tutorial by Damned has been really helpful in getting me started, but I am stuck on trying to modify the healing options without copying the entire file. I know you can use merge with things like windowclass, but what would the proper method be for modifying a function, or something in a function?

    For example, I want to use the slow natural healing variant as a base, since it's similar to the way my healing rule works. Instead of healing full HP, characters only heal 1/4 of their max HP with a long rest, but still recover half their HD. They can increase this to 50% HP and 75% HD by taking a full day of rest rather than 8 hours. On a short rest, the players are limited to spending up to 50% of their max HD (this doesn't really need to be included as a rule, since they can limit the number they spend very easily).

    I identified the slow natural heal string, and made a strings xml file with a new string name for my option following the steps in the video, and found that the healing option names are called in the data options lua file. My thought was to create a file that would modify just that options line so that it includes my option (and then also the line that refers to which option is selected in the character manager lua file so that the rule would apply when the option is selected). However, I'm not sure how to do this.

    What's the best way to go about changing the automated rules? Should I be creating a layered ruleset (in which case, I'll need some more help there too), or is there a more direct way to do this? Ideally I'd like to code it so that any updates to the 5e ruleset would automatically still be applied, regardless of if I am over-riding part of it with a custom rule.
    Thanks in advance!

  2. #2
    If you want to create a new game system, then you would create a ruleset.
    If you want to modify existing rules of a game system, then you would create an extension.

    In 5E, the behavior of "resting" is controlled via CombatManager2.rest (for all entries in combat tracker; when rest activated via combat tracker menu) and CharManager.rest (for PCs; used by combat tracker rest, as well as when activated via PC sheet radial menu).

    Since these are global scripts, you can sometimes override specific functions within the global scripts. (i.e. CombatManager.rest = <your function>). The main limitation is whether these functions are called internal to the global script or not. Any calls from within a global script will use the version defined in the global script. Any calls from outside a global script (i.e. CombatManager2.rest) will reference whatever is overriden or the base version. This has to do with the way scoping works in Lua. If you need to override local calls as well, then you could end up replacing multiple functions, which might be easier to replace the whole file.

    I'm guessing with your example goal; you'll probably be able to override those two rest(...) function entry points without having to replace the whole script.

    One note about replacing functions and/or scripts is that you may need to review future version updates to see if the files you've modified have been updated, so you can adjust your extension code accordingly. We push updates every 3-6 months to the ruleset code packs.

    Regards,
    JPG

  3. #3
    Thanks for the advice. Do functions named/defined in an extension folder automatically override any identically named functions in global scripts, or is there something I need to do to make it happen?

  4. #4
    No, they are each in their own file space.

    If you want to override a global script, window class or template, you have to redefine it.

    Regards,
    JPG

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
  •  
DICE PACKS BUNDLE

Log in

Log in