Starfinder Playlist
  1. #1

    Do onUpdate and onChildUpdate work for formattedtext nodes?

    I am coding an extension for Fantasy Grounds (Classic, but I don't think the difference matters for this issue) that sits atop the GURPS ruleset, which is in turn based upon the CoreRPG ruleset. I am trying to detect changes on a formattedtext node contained within various objects contained within list nodes, e.g.:
    Code:
    function onInit()
       DB.addHandler("charsheet.*.abilities.skilllist.*", "onChildUpdate", onSkillUpdooted);
    end
    
    function onSkillUpdooted(nSkill)
       ChatManager.SystemMessage("Aww yiss, I caught an update!");
    end
    My data's structure in db.xml looks something like this:
    Code:
    <root>
       <charsheet>
          <id-00001>
             <abilities>
                <skilllist>
                   <id-00001>
                      <!-- buncha nodes -->
                      <text type="formattedtext">
                         <h>Butt-Kicking (DX/VH)</h>
                         <p>Its dangerous to go alone, take this skill with you</p>
                         <linklist>
                            <!-- links are here -->
                         </linklist>
                      </text>
                      <!-- moar nodes -->
    I pick up changes to all the other nodes in the skilllist item, as one might expect. Since the structure of the data seems to indicate that the formattedtext node is a list of "runs" then I thought this would solve my problem:

    Code:
    function onInit()
       DB.addHandler("charsheet.*.abilities.skilllist.*", "onChildUpdate", onSkillUpdooted);
       DB.addHandler("charsheet.*.abilities.skilllist.*.text.*", "onChildUpdate", onSkillTextUpdooted);
    end
    
    function onSkillUpdooted(nSkill)
       ChatManager.SystemMessage("Aww yiss, I caught an update!");
    end
    
    function onSkillTextUpdooted(nUpdatedRun)
       ChatManager.SystemMessage("Tarnation! This never fires! Whyyyyyyy?");
    end
    FWIW I also tried picking up changes like this, because I like playing Battleship...
    Code:
       DB.addHandler("charsheet.*.abilities.skilllist.*.text", "onUpdate", onTheOffChanceThisWorks);
       DB.addHandler("charsheet.*.abilities.skilllist.*.text", "onChildUpdate", onTheOffChanceThisWorks);
       DB.addHandler("charsheet.*.abilities.skilllist.*.text.*", "onUpdate", onTheOffChanceThisWorks);
    Anyone have any secrets about how I can pickup changes in that node? Or am I just going to be sad and make people press a magic button to get the text to be parsed again when it changes.
    I wish my wife looked at me the same way that I look at my GURPS books.

  2. #2
    function onInit()
    DB.addHandler("charsheet.*.abilities.skilllist.*", "onChildUpdate", onSkillUpdooted);
    DB.addHandler("charsheet.*.abilities.skilllist.*.t ext", "onUpdate", onSkillTextUpdooted);
    end

    Have you tried it this way instead?

    Edit: I see that was one of the options. The one I have bold should do the trick. Since text doesn't have a child node the onChildUpdate won't work directly with the text node. The best location for onChildUpdate would be with the "charsheet.*.abilities.skilllist.*" set you showed. Since this has child nodes it will 'listen' to when these are changed and fire the script. I'm not sure if this is directly related to it being a formattedtext element or not, but might be as I never really have attempted to listen for changes in a formattedtext element.
    Last edited by superteddy57; October 22nd, 2020 at 22:23.
    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?-Idea Informer

  3. #3
    I have attempted your suggestion and failed successfully

    This page (it might no longer be valid) mentions that it is not bound to a database node.
    https://www.fantasygrounds.com/refdo...extcontrol.xcp

    I can almost hear Adam Savage in the background saying "Well, there's your problem!"

    I did do some rigging to see if the node was being updated at runtime (by capturing the parent (skill) node and calling a getText() on its "text" node. It's definitely getting pushed to the DB, I'm just straight up not getting notified about it.

    Having this work isn't a "must have" to pull off what I am trying to do, but it would be a lot cooler if it did.
    I wish my wife looked at me the same way that I look at my GURPS books.

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Newcastle, UK (for a bit)
    Posts
    27,765
    Quote Originally Posted by Baoghal View Post
    This page (it might no longer be valid) mentions that it is not bound to a database node.
    https://www.fantasygrounds.com/refdo...extcontrol.xcp
    That is still correct.

    A "control" is not linked to database data, but a "field" is. This is a key piece of FG terminology. So, the formatted text "field" is what stores data in the database: https://www.fantasygrounds.com/refdo...dtextfield.xcp

    That probably doesn’t address your issue, but it hopefully explains some terminology and the documentation.
    FG Con 16 Fantasy Grounds Online RPG Convention - Postponed New date To Be Confirmed.
    Register at www.fg-con.com for all the latest info.

    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
    Thank you for the clarification. As for this issue, is there another place where I should leave a bug report for it? I also have FGU, but I haven't moved my work over to it to see if the bug is there too.
    I wish my wife looked at me the same way that I look at my GURPS books.

  6. #6
    I just investigated this. It will work in FGU, but not FGC.

    It was by design in FGC by the original developers (before my time) based on the way formatted text fields are implemented and dealing with performance. With FGU, it was completely rebuilt, and the proposed solution will work (in FGU only). Unfortunately, there is no easy way to make this work in FGC without rewriting whole portions of formatted text fields; and there are no plans to spend that much development time on FGC given FGU work.

    The workaround is to use the onValueChanged event in the formattedtextcontrol/formattedtextfield to capture the changes; and apply whatever actions you want.

    Regards,
    JPG

  7. #7
    Ah ha! Thank you! It's almost time to move, then
    I wish my wife looked at me the same way that I look at my GURPS books.

Thread Information

Users Browsing this Thread

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

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