DICE PACKS BUNDLE
  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:

    Code:
                                            function onListChanged()
    						Total = getWindowCount();
    						if Total > 1 then
    							for _,w in pairs(getWindows()) do
    								w.destroy(self);
    							end
    						end
    					end
    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?

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,361
    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.
    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()

    Regards,
    JPG

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
  •  
FG Spreadshirt Swag

Log in

Log in