Starfinder Playlist
  1. #1

    A plea regarding the database

    I'm currently struggling a bit with the FG database...
    Can someone give me a pointer on how you'd store and then get the information back from a table i.e
    if I had a table :
    name1 value 1
    name2 value2
    name 3 value 3
    etc

    what would be the preferred/best way to store this in the database?

    Cheers, Steve.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    Is this a dynamic table or a table with fixed rows?

    Does the data need to be individually accessed, or is it just for reference?

    If you have a dynamic table - essentially a list (these are all over the place in FG), these can be displayed in the windowlist control: https://fantasygroundsunity.atlassia...373/windowlist

    The underlying database structure will be something like the following (this is a skill list from PF2):
    Code:
    <skilllist>
    	<id-00001>
    		<armorcheckmultiplier type="number">0</armorcheckmultiplier>
    		<label type="string">Arcana</label>
    		<misc type="number">0</misc>
    		<prof type="number">0</prof>
    		<showonminisheet type="number">1</showonminisheet>
    		<stat type="number">0</stat>
    		<state type="number">0</state>
    		<statname type="string">intelligence</statname>
    		<total type="number">0</total>
    	</id-00001>
    	<id-00002>
    		<armorcheckmultiplier type="number">0</armorcheckmultiplier>
    		<label type="string">Occultism</label>
    		<misc type="number">0</misc>
    		<prof type="number">3</prof>
    		<proflevel type="string">trained</proflevel>
    		<showonminisheet type="number">1</showonminisheet>
    		<stat type="number">0</stat>
    		<state type="number">0</state>
    		<statname type="string">intelligence</statname>
    		<total type="number">3</total>
    	</id-00002>
    	<id-00003>
    		<armorcheckmultiplier type="number">0</armorcheckmultiplier>
    		<label type="string">Diplomacy</label>
    		<misc type="number">0</misc>
    		<prof type="number">0</prof>
    		<showonminisheet type="number">1</showonminisheet>
    		<stat type="number">-1</stat>
    		<state type="number">0</state>
    		<statname type="string">charisma</statname>
    		<total type="number">-1</total>
    	</id-00003>
    	<id-00004>
    		<armorcheckmultiplier type="number">0</armorcheckmultiplier>
    		<label type="string">Nature</label>
    		<misc type="number">0</misc>
    		<prof type="number">0</prof>
    		<showonminisheet type="number">1</showonminisheet>
    		<stat type="number">2</stat>
    		<state type="number">0</state>
    		<statname type="string">wisdom</statname>
    		<total type="number">2</total>
    	</id-00004>
    </skilllist>
    Adding a new row to the table automatically adds a new <id-XXXXX> intermediate node to the database structure.

    You can use the API in the windowlist (linked above) to navigate data, but this relies on the windowlist being open. You're best navigating this data in code using the database - https://fantasygroundsunity.atlassia...ges/4063529/DB and https://fantasygroundsunity.atlassia...0/databasenode

    Info on the database here: https://fantasygroundsunity.atlassia...set+-+Database
    Last edited by Trenloe; May 28th, 2020 at 10:47.
    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
    Thanks for replying Trenloe,
    The structure you've posted is pretty much what I'm after, I just need to be able to create/reference it from withng a lua function. That's the bit I'm struggling with (I've never been very good with database manipulation, even going back years ago to Dataease :O
    I'll have another look at it and see if I can figure it out.

    Cheers, Steve.

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    Don't think of FG as a "database" in terms of a relational database. It's basically a flat file. So you're operating against a clearly visible hierarchy.

    Adding things to an existing entry is usually with createChild - where you create a child node of an existing node. See here: https://fantasygroundsunity.atlassia...DB#createChild or here: https://fantasygroundsunity.atlassia...de#createChild

    To create a new intermediate node in the skilllist example above, use newChildNode = DB.createChild(soruceNode)

    Where newChildNode is the new node you've created - it'll be an intermediate node <id-XXXX> in the DB structure. And soruceNodeis the skilllist node identifier.

    Then you can use newChildNode (which is a databasenode object) to create new children nodes - like name, or value, etc.. Info on the databasenode object here: https://fantasygroundsunity.atlassia...0/databasenode
    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 again Trenloe,
    I think I get the gist of that
    I'll have a mess around and see if I can get things to work out.

    Cheers, Steve.

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

Log in

Log in