Joshua Stream Pre
  1. #1
    bmos's Avatar
    Join Date
    Jun 2019
    Location
    Maine, USA
    Posts
    802

    create new list item from lua script

    I am trying to add an item to the character's inventory list from a script that is not within the campaigns folder.
    Does anyone have an example of how this is done?

    It seems like createWindow() is used in campaign/scripts but that doesn't work in regular scripts.
    I have an idea to look for maximum ID # in inventorylist and then title the new node as that number + 1, but this seems like an over-complicated approach.

    PF1e ruleset
    bmos' pathfinder 1e extensions
    Discord Tag: wil.thieme#3396

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Isle of Wight, UK (for a bit)
    Posts
    27,562
    Yep, use <windowlist>.createWindow()

    https://fantasygroundsunity.atlassia...t#createWindow

    The key here is that you'll need to get the instance of the windowlist control to be able to use that API command.

    It is often better to create a new DB child, which will have a similar effect, but can be better going direct to the database (and a repeatable location once you have nodeChar) than worrying about working out how to navigate the GUI hierarchy to get the windowlist control instance.
    FG Con 16 Fantasy Grounds Online RPG Convention - Postponed New date To Be Confirmed.
    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
    bmos's Avatar
    Join Date
    Jun 2019
    Location
    Maine, USA
    Posts
    802
    Quote Originally Posted by Trenloe View Post
    It is often better to create a new DB child, which will have a similar effect, but can be better going direct to the database (and a repeatable location once you have nodeChar) than worrying about working out how to navigate the GUI hierarchy to get the windowlist control instance.
    This is actually what I was meaning. I just don't know how to give it the correct name (id-00001 vs id-00002 and so forth). Does it do that automatically if I don't specify a name?

    EDIT: yes it does
    Thanks Trenloe.
    Last edited by bmos; September 22nd, 2020 at 01:33.
    bmos' pathfinder 1e extensions
    Discord Tag: wil.thieme#3396

  4. #4
    When you use DB.createChild() it will automatically add a new id# in the sequence. So example:

    Say we want to script in adding a new character sheet, but want it to have a certain charisma bonus each time. So the DB in dot notation would look like this, charsheet.#.abilities.charisma.bonus. The '#' is the id# of each character sheet in the campaign/module structure. Since we don't need to assign it a name FG assigns it a id# in sequence. So if I go to the root and then run DB.createChild() on charsheet, it will then create nodes with the id# sequence (id-00001 .. id-00002 .. id-00003). So yes, it will add it in automatically and you see this behavior across the DB within the campaign as FG doesn't create meaningful names for list nodes.
    How to provide an Unity Connection issue?-Connection Issues and What to Provide

    Unity Updater issue?-Updater Issues

    Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained

    Comcast or Cox ISP User?-Comcast XFinity and Cox Users

    Have a suggestion?-Idea Informer

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

Log in

Log in