1. #1

    [Programming] Limit windowlist entries?

    hey guys! so i wanted to add careers to my Alien RPG ruleset, and i'm having an issue. I figured i could use a windowlist and just make it delete the old entries when a new one is dropped in, but i'm struggling.

    i've tried in the script of the windowlist:

                                            function onListChanged()
    						Total = getWindowCount();
    						if Total > 1 then
    							for _,w in pairs(getWindows()) do
    and if i do that as just "destroy()" or "destroy(w)" instead of "w.destroy()" it crashes fantasy grounds.

    i can't find a way to simply limit it. what am i missing? what else could i do to have a single "career" record on a character sheet?
    “The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents. We live on a placid island of ignorance in the midst of black seas of the infinity, and it was not meant that we should voyage far.”
    ― H. P. Lovecraft, The Call of Cthulhu and Other Weird Stories

    “The oldest and strongest emotion of mankind is fear, and the oldest and strongest kind of fear is fear of the unknown”
    ― H.P. Lovecraft, Supernatural Horror in Literature

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Denver, Colorado, USA (for a bit)
    Quote Originally Posted by pr6i6e6st View Post
    and if i do that as just "destroy()" or "destroy(w)" instead of "w.destroy()" it crashes fantasy grounds.
    Calling destroy without a reference object means that the API function will be executed on the currently in scope object/control - which I'm guessing is the windowlist control.

    As you would then be destroying the control that you were running code against, this causes an exception.

    Calling w.destroy means you're destroying a specific control within the windowlist.

    Info on <control>.destroy here: https://www.fantasygrounds.com/refdo...ol.xcp#destroy

    The best practice for doing anything like this is to operate against the underlying database records - which the windowlist is anchored on. When a new record is added, remove the old record.

    I'm not familiar with your ruleset, so not sure why you're using a windowlist to display one record. Most other rulesets just display the title for something like career with a link to open the database record for more information. A drag/drop of a new career record would be coded to replace the previous name and record link.
    FG Con 16 – Fantasy Grounds Online RPG Convention - Friday April 24th to Sunday April 26th, 2020
    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!

  3. #3
    I would either manage completely through the database (and thus not mess with any windowlist APIs for addition/creation);
    OR manage all window creation and deletion through the APIs and not tie it to the database.

    If you want to close all windows in a sourceless windowlist (i.e. not connected to database), use windowlist.closeAll()
    If you want to create a window in a sourceless windowlist, use windowlist.createWindow(record) or windowlist.createWindowWithClass(class, record)
    If you want to close a single window, use windowinstance.close()


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