Starfinder Playlist
Page 1 of 2 12 Last
  1. #1

    NPC DB - CT correlation

    Another proably stupid question :

    If I have the DB node of an NPC in the CT, how do I get the window reference to that NPC in the CT so I can use things like window.setFrame etc.


    Cheers, Steve.

  2. #2
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,678
    Blog Entries
    1
    I dont understand the Q.
    When you add a NPC to the CT it creates a copy of the NPC in the DB.
    That is because the bulk of NPCs are dupes.

  3. #3
    I'm not explaining myself very well :P , so here's a quick example :

    If I have 2 actors in the CT let's call them npc1 and npc2.
    I want to be able to change the graphical frame surrounding them n the combat tracker window.
    So by my understanding to be able to do this via 'npc1window.setFrame' (paraphrasing the command to do so) then I would need to have npc1's window reference inside of the combat tracker window.
    This is what I'm struggling with.

    I hope that's clearer, and I also hope you can help

    Cheers, Steve.

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    You'll need to get the windows from the CT windowlist, iterate through them until you find one with the same database node - don't use the NPC name as that isn't unique.

    Get the windows in the CT using the windowlist getWindows API command: https://fantasygroundsunity.atlassia...ist#getWindows

    Then iterate through using for key,window in pairs(windowlist.getWindows()) do... Window is the window instance for each CT entry as you iterate through.


    Then use getDatabaseNode: https://fantasygroundsunity.atlassia...etDatabaseNode and getNodeName: https://fantasygroundsunity.atlassia...de#getNodeName to get the database node name the window is sourced from, and compare that with the database node name of the NPC CT record - then you'll have the window instance of the CT entry, and can do GUI "stuff" against that.
    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
    Thanks for the reply Trenloe.
    I'm now going to show my ignorance
    Get the windows in the CT using the windowlist getWindows API command: https://fantasygroundsunity.atlassia...ist#getWindows
    This is the bit I'm really having a hard time with, I can't seem to find the correct way of writing this.
    Can you point me to a code example ?

    Cheers, Steve.

    *edit*
    I meant to add that I'm attempting this from within my own functions, not from within the CT window instance.
    Last edited by Stv; July 4th, 2020 at 16:37.

  6. #6
    So to further clarify,
    using getWindows() in CT.lua returns the window references to the CT actors, which is what I need.
    So I need to know how to get this functionality from within my main lua file which is not immediatley associated with the CT.lua functions.

    Cheers, Steve.

  7. #7
    I 've come up with a dirty workaround. It's messy but it works.
    From within the ct.lua onInit function I store the 'self' value in a global variable. This is a pointer to the combat tracker windows that I need to reference elsewhere.
    I'm sure there's a much better solution, but this works for now, until I can figure out how to do this better.

    Cheers, Steve.

  8. #8
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    To get the top level Combat Tracker window instance use Interface.findWindow("combattracker_host", "combattracker"); on the GM side. https://fantasygroundsunity.atlassia...ace#findWindow

    If you want to do this on the PC side substitute combattracker_client for combattracker_host.
    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
    Thanks Trenloe,
    That's not what I'm after though. the 'self' from ct.lua returns a windowlist with the actor windows contained in it, whereas the interface.findwindow returns the windowinstance of the combat tracker and I'm too dumb to figure out how to use the windowinstance to get the information I need :P

    Cheers, Steve.

  10. #10
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    The window instance returned is created with the combattracker_host windowclass - defined in ct_host.xml.

    Within that windowclass are all the CT controls - including list_ctbox_host which is the windowlist control you're looking for.

    <windowinstance>.<control name> gives the control. So, if you use local wCT = Interface.findWindow("combattracker_host", "combattracker"); to get the windowinstance of the CT, wCT.list_ctbox_host will give you the windowlist control.
    Last edited by Trenloe; July 5th, 2020 at 14:21.
    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
  •  
5E Character Create Playlist

Log in

Log in