STAR TREK 2d20
  1. #1

    Help With Accessing Controls On Other (Peer) Subwindows

    Hi Guys,

    Yeah, I'm at that stage again - been coding all day and now I'm tired and beating my head against my favourite brick wall again.

    I've got a windowreferencecontrol (wrc01) sitting on a subwindow (sw01) and I need to perform a getWindows() call (wrc01.getWindows()) from a second subwindow (sw02). Both subwindows are children of the same parent window (main).

    I've got my call as follow:

    Code:
    for kKey,oWindow in pairs(parentcontrol.window.sw01.subwindow.wrc01.getWindows()) do
        {stuff happeneds};
    end
    Unfortunately I'm getting the following error:

    Code:
    Script Error: [string "sw02_script.lua"]:73: attempt to index field 'subwindow' (a nil value)
    Any help would be appreciated.

    Thanks
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    Firstly, getWindows() will not work on a windowreferencecontrol, it is usually used with windowlist controls.

    In reference to the subwindow being nil, I recommend that you step through your control hierarchy and make sure that you are where you think you are with the code you're using. For debugging your control hierarchy I recommend taking it one step at a time and output the control name/class name to the console. This should, with just a couple of Debug.console commands, give you an idea if you are accessing controls you think you are.

    For example:
    Code:
    Debug.console("parentcontrol = " .. parentcontrol.getName());
    Debug.console("parentcontrol.window = " .. parentcontrol.window.getClass());
    Debug.console("parentcontrol.window.sw01 = " .. parentcontrol.window.sw01.getName());
    Depending on what the actual element you are referencing is (a control or a window instance) you may need to swap getName (for a control) with getClass (for a window instance), or vice versa.
    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!

  3. #3
    Quote Originally Posted by Trenloe View Post
    Firstly, getWindows() will not work on a windowreferencecontrol, it is usually used with windowlist controls.
    Sorry, typo in my post (told you I was tired).

    Post should read <corrected post>:

    I've got a windowinstance (wi01) sitting on a subwindow (sw01) and I need to perform a getWindows() call (wrc01.getWindows()) from a second subwindow (sw02). Both subwindows are children of the same parent window (main).

    I've got my call as follow:

    Code:
    for kKey,oWindow in pairs(parentcontrol.window.sw01.subwindow.wi01.getWindows()) do
        {stuff happens};
    end
    Unfortunately I'm getting the following error:

    Code:
    Script Error: [string "sw02_script.lua"]:73: attempt to index field 'subwindow' (a nil value)
    </corrected post>

    This, unfortunately, doesn't change the jist of the question - I'm not even getting down to the windowinstance as it's bombing-out at the parent subwindow (sw01).

    Quote Originally Posted by Trenloe View Post
    In reference to the subwindow being nil, I recommend that you step through your control hierarchy and make sure that you are where you think you are with the code you're using. For debugging your control hierarchy I recommend taking it one step at a time and output the control name/class name to the console. This should, with just a couple of Debug.console commands, give you an idea if you are accessing controls you think you are.

    For example:
    Code:
    Debug.console("parentcontrol = " .. parentcontrol.getName());
    Debug.console("parentcontrol.window = " .. parentcontrol.window.getClass());
    Debug.console("parentcontrol.window.sw01 = " .. parentcontrol.window.sw01.getName());
    Depending on what the actual element you are referencing is (a control or a window instance) you may need to swap getName (for a control) with getClass (for a window instance), or vice versa.
    Yeah, I was trying to avoid having to do that (as I said, I was tired) - I was hoping that someone would see an "obvious" mistake that they could point out while I slept - if no-one had found anything then I was going to take your suggested route when I get back to it tomorrow.

    Thanks Tren
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  4. #4
    Found it!

    Forgot to put in a <fastinit /> in my <subwindow> definition.

    I REALLY have to stop coding when I'm tired!

    Cheers
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  5. #5
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    Firstly, getWindows() won't work against a window instance. A window instance is a single instance of a window, it doesn't have any other windows it is a window in itself. https://www.fantasygrounds.com/refdo...owinstance.xcp

    To go back to the jist of your question, I'm not 100% sure as I don't have access to your XML, but I think it is the subwindow.wi1 portion that could be failing. without seeing your XML, I think that subwindow is actually the window instance wi1

    See what Debug.console("parentcontrol.window.sw01.subwindow = " .. parentcontrol.window.sw01.subwindow.getClass()); shows you, this might be the window instance you are looking for. But, remember that getWindows will not work on this - you only have one window instance and at this point you probably have the reference to it.
    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!

  6. #6
    Gawd, I can't even get my corrects right tonight!

    Let's try again - third time's the charm, as they say.

    Right, its not a windowinstance nor is it a windowreferencecontrol, it's a windowlist!

    Sometimes I should just walk away...

    Anyway, as I said in Post #4, I found the issue - I needed to <fastinit /> in my <subwindow> definition.

    I've tested it, it works, and now I'm going to bed!

    Cheers
    Dulux-Oz

    √(-1) 2^3 Σ Π
    ...And it was Delicious!


    Alpha-Geek
    ICT Professional
    GMing Since 1982
    NSW, Australia, UTC +10
    LinkedIn Profile: www.linkedin.com/in/mjblack

    Watch our games on Twitch: www.twitch.tv/dulux_oz

    Support Me on Patreon: www.patreon.com/duluxoz

    Past Games, etc, on my YouTube Channel: www.youtube.com/c/duluxoz

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    Quote Originally Posted by dulux-oz View Post
    Sometimes I should just walk away...
    Yeah.
    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!

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
  •  
Starfinder Playlist

Log in

Log in