1. #1

    Return order of getChildren as per XML order

    Afternoon Folks,

    I've got a node which stores the results of the dice rolls. Works lovely:

    <savedroll>
    <id-00004>
    <result type="number">6</result>
    </id-00004>
    <id-00005>
    <result type="number">10</result>
    </id-00005>
    <id-00006>
    <result type="number">3</result>
    </id-00006>
    </savedroll>
    However when I do a DB call and get the children, they come in a random order, last time it was:

    Runtime Notice: s'v' | databasenode = { charsheet.id-00005.savedroll.id-00006 }
    Runtime Notice: s'v' | databasenode = { charsheet.id-00005.savedroll.id-00005 }
    Runtime Notice: s'v' | databasenode = { charsheet.id-00005.savedroll.id-00004 }
    Next time it was 8,9,7

    Any thoughts?

    Cheers
    MBM

  2. #2
    Ikael's Avatar
    Join Date
    Jan 2008
    Location
    Finland/Joensuu
    Posts
    2,027
    That is correct. DB.getChildren does not return in order where they are presented in XML, instead they are identified by their node name (string type) in table and when you use pairs to iterate them through they seem to come out in "random" order. In SavageWorlds I had need to get them in asc order so I have implemented getChildrenSorted function t achieve that.

    Quote Originally Posted by MadBeardMan View Post
    Afternoon Folks,

    I've got a node which stores the results of the dice rolls. Works lovely:



    However when I do a DB call and get the children, they come in a random order, last time it was:



    Next time it was 8,9,7

    Any thoughts?

    Cheers
    MBM
    "Alright, you primitive screwheads, listen up: THIS... is my BOOMSTICK!" -- Ash Williams, Army of Darkness

    Post your SavageWorlds ruleset feature requests and issue reports here!

    Enhance your core Savage Worlds ruleset with SW Enhancement Extensions, get more to savage!
    Want to create SW NPCs quickly? Use SW NPC Maker extension!
    Want to prove your dices are cursed or blessed? Try out SW Roll Statistics

  3. #3
    Quote Originally Posted by Ikael View Post
    That is correct. DB.getChildren does not return in order where they are presented in XML, instead they are identified by their node name (string type) in table and when you use pairs to iterate them through they seem to come out in "random" order. In SavageWorlds I had need to get them in asc order so I have implemented getChildrenSorted function t achieve that.
    It's ok I fixed it myself.

    I now have the 'dice' number stored along with the result, and it sets the 'Dice..i' with that value.

    Cheers!
    MBM

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