5E Product Walkthrough Playlist
  1. #1

    Unity: getValue called by handler returns previous value

    I noticed that my Total Encumbrance extension isn't quite behaving itself in FGU.
    I have this line in onInit:
    Code:
    DB.addHandler(DB.getPath('charsheet.*.inventorylist.*.carried'), 'onUpdate', applyPenalties)
    which eventually triggers a getValue:
    Code:
    local total = DB.getValue(nodeChar, 'encumbrance.total', 0)
    which in FGC returns the value after toggling the 'carried/equipped/dropped' button that triggers this code, but in FGU returns the value before clicking the button.
    Is there a simple alternative that will return the value after clicking on both systems?

    Pathfinder ruleset.
    Last edited by bmos; July 9th, 2020 at 12:39.

  2. #2
    I think that the problem you're running into is that there is no guarantee of handler trigger order, partially because Lua handler triggers are implemented in Lua (at least in FGC) and have no inherent order.

    Have you thought about triggering the applyPenalties when "chatsheet.*.encumbrance.load" is updated instead?

    Regards,
    JPG

  3. #3
    Quote Originally Posted by Moon Wizard View Post
    I think that the problem you're running into is that there is no guarantee of handler trigger order, partially because Lua handler triggers are implemented in Lua (at least in FGC) and have no inherent order.

    Have you thought about triggering the applyPenalties when "chatsheet.*.encumbrance.load" is updated instead?

    Regards,
    JPG
    Unfortunately, I need to trigger the script for all three states, not just carried/noncarried. It also needs to occur for zero-weight items.

  4. #4
    Perhaps you can break up the part of the code tied to the total encumbrance updates from the carried updates?

    JPG

  5. #5
    Quote Originally Posted by Moon Wizard View Post
    Perhaps you can break up the part of the code tied to the total encumbrance updates from the carried updates?

    JPG
    That's a thought and something I have been telling myself I need to do someday, anyway. Thanks

  6. #6
    disregard
    Last edited by bmos; July 23rd, 2020 at 11:08.

  7. #7
    Unfortunately, after changing the code, it's still behaving the same.

    This has brought me to a realization:
    It's not because of the handlers

    Instead of a handler, I added a script tag to the carried button's xml which should get around any handler-timing unpredictability.

    It sees the "carried" value change, but the total carried lags behind the carried state.

    I guess this means that the code to add-up inventory weight is running after my script in FGU but not FGC.

    I'm working around it by adding the same trigger script tag to charsheet.*.encumbrance.load for the time being as you suggested.

    Is there a way to check if the user is using unity? Some sort of version check function?
    Last edited by bmos; July 23rd, 2020 at 11:47.

  8. #8
    There are two ways to check for versioning that I can think of using.

    You can check if a windowclass should be used by placing a version=">=4" in the tag. Example:

    <windowclass name="imagewindow" version="&gt;=4">

    For lua, you can do an if/then statement to check for version. An Example:

    if Interface.getVersion() >= 4 then

    This of course works for checking for FGC by using the inverse of the code I presented.
    Dominic Morta
    Ruleset Developer
    Smiteworks

    How to zip up your campaign if the Developers ask for it-How to zip up your campaign if the Developers ask for it

    How to provide an Unity Connection issue?-Connection Issues and What to Provide

    Unity Updater issue?-Updater Issues

    Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained

    Comcast or Cox ISP User?-Comcast XFinity and Cox Users

    Have a suggestion?-Feature Request

  9. #9
    thanks!

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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
  •  
STAR TREK 2d20

Log in

Log in