1. #1

    DB.getValue() for a shortcut node does not return the entered path

    Hi,

    I'm trying to run DB.getValue(node, childname) on a node in a module I've created. The function should return the recordname entered at that path, which is "[email protected] Core Rulebook" but instead I get "[email protected] test".

    The code I'm running is this:
    Code:
           local the_node = DB.findNode("[email protected] test")
         if the_node then
             local shortcut_class, shortcut_nodeid = DB.getValue(the_node, "shortcut")
             Debug.chat("FOUND shortcut:", shortcut_class, shortcut_nodeid)
         else
             Debug.chat("Didn't find in found module ", sModule)
         end
    and I'm adding it in the manager_version.lua in corerpg, in the end of the function onModuleLoad().

    The module can be downloaded from https://web.rahmqvistcloud.se/share/X0Lq62f and is easy to unzip if you want to check the xml-values.

    Does anybody understand why this is happening and could please explain to me what I'm doing wrong? I have this issue in a new module that we're writing and we can't complete it unless we find out why our cross-module links don't work. It seems to work nicely linking to nodes within a module.

    Thanks,
    Simon

  2. #2
    Is "Symbaroum Core Rulebook" a read only module? If it is try removing the RO flag (I'm assuming this is your module), re-export then try.
    ---
    DM/Play: AD&D (any flavor)
    Coding the Official AD&D Ruleset

  3. #3
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Denver, Colorado, USA (for a bit)
    Posts
    22,625
    A couple of general FG coding things here -
    1) You're trying to return the DB.getValue of the shortcut DB node in the database - this doesn't have a value: <shortcut type="windowreference">
    2) You're looking for 2 return values, whereas DB.getValue will only return 1.

    You could try:
    Code:
    local shortcut_class = DB.getValue(the_node, "shortcut.class")
    local shortcut_nodeid = DB.getValue(the_node, "shortcut.recordname")
    I haven't tested the above, so don't know if that will work. The FG API very often restricts which DB nodes you can access with LUA code, especially within a specific DB node structure (for example, you can't access all of the <image> node data directly in the FG database). I don't know if this will be the case with this example, as FG *might* restrict accessing data in a <shortcut type="windowreference"> DB node, but I don't know if this is the case here. You could try DB.getValue(the_node, "name") and see if that returned "Armored" OK, and if the other DB.getValue entries I list above don't work, it could well be the case that the FG API is not allowing access.
    Last edited by Trenloe; June 3rd, 2019 at 16:05.


    FG Product Development status: Pathfinder Playtest Ruleset and add-ons: In development. Pathfinder Bestiary, Pathfinder Bestiary 2, Pathfinder Bestiary 3 (in store).

    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!

  4. #4
    Ok, I put the module in my modules folder, then added your code at the end of CoreRPG::VersionManager:: onModuleLoad.
    Next, I created a new Symbaroum campaign, went to the library, and opened the bad link module.

    Here's what I got; so it looks like it is working. (see picture)

    JPG
    Attached Images Attached Images

  5. #5
    Hi all and thanks for the answers!

    Trenloe: I think it's special when it comes to windowreferences, as that's a special value-type in the database. DB.getValue for windowreference returns 2 values afaik.

    Moon Wizard: That's weird, why isn't it working for either me or my companion?

    I just tried it and got this:

    Thanks,
    Simon
    Attached Images Attached Images

  6. #6
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Denver, Colorado, USA (for a bit)
    Posts
    22,625
    Quote Originally Posted by Simpe View Post
    Trenloe: I think it's special when it comes to windowreferences, as that's a special value-type in the database. DB.getValue for windowreference returns 2 values afaik.
    Good to know - thanks!


    FG Product Development status: Pathfinder Playtest Ruleset and add-ons: In development. Pathfinder Bestiary, Pathfinder Bestiary 2, Pathfinder Bestiary 3 (in store).

    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
    Simpe,

    My guess is that you have other changes going on that are not accounted for in the sample you sent.

    Your best bet is to reset FG to the basic installs without any changes to the files. (i.e. rename current FG data folder, and re-install from scratch) Then, create a very basic extension to add a simple script which registers an onModuleLoad handler to test your code, and only add that extension and module to your FG data folder.

    Basically, when something doesn't work like it does on someone else's machine, it's always best to save off your work and reset your environment so you're on the same page as everyone else.

    Regards,
    JPG

  8. #8
    Moon Wizard,

    Yes you were correct. I tried it in another ruleset and the link works. What could I possibly have done in the ruleset that modifies how links are fetched from the DB?

    EDIT: I found out that if I wrap the <npc> tag within the module inside a <reference static="true"> then the link prevails and works. Which is weird, I don't have any code that goes through and modifies links.

    Thanks for helping!
    Last edited by Simpe; June 5th, 2019 at 04:20.

  9. #9
    Hi again,

    I'm still seeing issues with this.

    I've started seeing it in our core ruleset where whe have links such as:
    Code:
                            <shortcut type="windowreference">
                                <class>reference_mystical_power</class>
                                <recordname>[email protected] Core Rulebook - Player's Guide</recordname>
                            </shortcut>
    but when I fetch it (without modifying it), it turns out to be:
    Code:
    [email protected] Core Rulebook
    The <npcs> tag has static set to true, which I assume then means that all children of that node is static as well? Is there anything related to this that has changed during the last month or so? We haven't had this issue before and it has started appearing pretty recently. Now I'm not sure how to debug it or how to proceed.

    EDIT: We haven't changed these links since release and they've only started to break now recently.

    Thanks for any help,
    Simon

  10. #10
    Ok so I solved it.

    The culprit is that we have the following behavior:
    If you drop an ability/trait whatever onto your charactersheet or your npc which is modifiable, then the link should be updated to a copied version of the ability/trait. The copy is only done upon drag-and-drop.

    Since the npc's don't have drag-and-dropped (they have hardcoded links to the items), the code was not checking for if the link that it was changing belonged to a node that was write protected. Apparently, write protected nodes are possible to write to but it causes the side effect of copying the entire node to a place where it is editable.

    So what we did was that we changed the link to be to itself in certain cases, and some other code had changed this situation to happen 100% for nodes which were not editable.

    So, problem solved - it was local all along

    Thanks!
    Simon

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
  •  

Log in

Log in