5E Product Walkthrough Playlist
Page 1 of 2 12 Last
  1. #1

    Subwindows and "back referencing" query

    I'm trying to call a function from within 2 subwindows all the way back to the top. I'm having trouble finguring it out tho.

    The setup is this.

    windowclass(readycheck)
    -subwindow(main)
    --windowclass(ready_check_main)
    ---subwindow(main_user)
    ----windowclass(ready_check_entry_user)

    From within ready_check_entry_user I want to have a button_checkbox via onValueChanged() refer back to a function in "readycheck".

    I'm having trouble figuring out the "path" BACK to readycheck. window.function refers to the script within the windowclass "ready_check_entry_user" so that's not helpful. Been trying to figure out parentcontrol but that doesn't seem to get things back where I need either.

    Anyone have some tips on how to reference backwards?
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  2. #2

  3. #3
    Quote Originally Posted by damned View Post
    Side trip - can you not do this by referencing the DB directly?
    There is no node associated with the subwindow that the button_checkbox resides. It's non-persistent data that I just need to know they clicked at that moment. I'm triggering a oob notify.

    I'll attach the xml file.
    Attached Files Attached Files
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,407
    You're probably going to have to string parentcontrol and subwindow together: https://www.fantasygrounds.com/refdoc/subwindow.xcp

    When I need to work these out I will use lots of Debug.console commands outputting the control name or window instance class name.

    So things like: window.getClass() or parentcontrol.getName() and then string them together - window.parentcontrol.getName() etc..

    You'll get some nil errors, but it usually helps to go through it a few times to work out the exact hierarchy and how you can string the various API references together.
    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
    You're probably going to have to string parentcontrol and subwindow together: https://www.fantasygrounds.com/refdoc/subwindow.xcp

    When I need to work these out I will use lots of Debug.console commands outputting the control name or window instance class name.

    So things like: window.getClass() or parentcontrol.getName() and then string them together - window.parentcontrol.getName() etc..

    You'll get some nil errors, but it usually helps to go through it a few times to work out the exact hierarchy and how you can string the various API references together.
    That was what I was trying to do and I got to window.parentcontrol.subwindow. After that I couldn't get any further back up. I'll look at the notes you linked and see if I can figure out why.
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  6. #6
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,407
    Quote Originally Posted by celestian View Post
    That was what I was trying to do and I got to window.parentcontrol.subwindow. After that I couldn't get any further back up. I'll look at the notes you linked and see if I can figure out why.
    Did you try window.parentcontrol.subwindow.window as the next step?
    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
    Did you try window.parentcontrol.subwindow.window as the next step?
    Yup, here is the code I ran from the button and the output I got.


    Code:
              function onButtonPress()
                local sName = User.getUsername();
                window.notifyReadyCheck(sName,1);
                Debug.console("PC0","window",window);
                Debug.console("PC1","window.getClass()",window.getClass());
                Debug.console("PC2","window.subwindow",window.subwindow);
                Debug.console("PC3","window.parentcontrol",window.parentcontrol);
                Debug.console("PC4","window.parentcontrol.getName()",window.parentcontrol.getName());
                Debug.console("PC6","window.parentcontrol.subwindow",window.parentcontrol.subwindow);
                Debug.console("PC7","window.parentcontrol.subwindow.getClass()",window.parentcontrol.subwindow.getClass());
                Debug.console("PC8","window.parentcontrol.subwindow.window",window.parentcontrol.subwindow.window);
              end
    Code:
    Runtime Notice: s'PC0' | s'window' | windowinstance = { class = ready_check_entry_user, node = nil, x,y,w,h = 371,295,246,45 }
    Runtime Notice: s'PC1' | s'window.getClass()' | s'ready_check_entry_user'
    Runtime Notice: s'PC2' | s'window.subwindow' | nil
    Runtime Notice: s'PC3' | s'window.parentcontrol' | subwindow = { x,y,w,h = 0,15,246,45 }
    Runtime Notice: s'PC4' | s'window.parentcontrol.getName()' | s'main_user'
    Runtime Notice: s'PC6' | s'window.parentcontrol.subwindow' | windowinstance = { class = ready_check_entry_user, node = nil, x,y,w,h = 371,295,246,45 }
    Runtime Notice: s'PC7' | s'window.parentcontrol.subwindow.getClass()' | s'ready_check_entry_user'
    Runtime Notice: s'PC8' | s'window.parentcontrol.subwindow.window' | nil
    Script Error: [string ""]:1: attempt to index field 'window' (a nil value)
    As you can see the "main_user" is right here:

    windowclass(readycheck)
    -subwindow(main)
    --windowclass(ready_check_main)
    ---subwindow(main_user)<--------------
    ----windowclass(ready_check_entry_user)
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  8. #8
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,407
    OK, so window = ready_check_entry_user and window.parentcontrol.subwindow also = ready_check_entry_user.

    So you've gone up then back down with subwindow.

    How about window.parentcontrol.window?
    Last edited by Trenloe; February 28th, 2018 at 04:11.
    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!

  9. #9
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,407
    The "Scope" section here might also give you some ideas: https://www.fantasygrounds.com/wiki/...pt_Block_Scope

    For this you're probably going to need something like: window.parentcontrol.window.parentcontrol.window
    Last edited by Trenloe; February 28th, 2018 at 04:12.
    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!

  10. #10

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Celestian, I usually give up and create a temporary node in these cases because I can never walk back up very far. I create the node and then delete it when I'm done. A kluge, but I get brain damage trying to walk up window/subwindow hierarchies like that.

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