Modding Discussion __merge issue with nested arrays/lists

Discussion in 'Starbound Modding' started by Annuschka, Dec 23, 2013.

  1. Technius

    Technius Starship Captain

    The object-only structure is a lot cleaner. The nested array structure is sort of like an SQL database: A table of names and then IDs that refer to other tables. Confusing, slow, and difficult to parse. Tree structures are much easier to parse, and are generally faster, too.
     
    Annuschka likes this.
  2. Annuschka

    Annuschka Big Damn Hero

    Yeah for those "structured" arrays, like the two genders, it seems a lot more locical to use objects and named values. But there is certainly a reason why the Devs choose to nest it into arrays in the first place... :coffee:

    Tiy just twittered something:
    Maybe this will help somehow? ... .... :wut:
     
  3. Annuschka

    Annuschka Big Damn Hero

    Am I cursed or what?! Starting a new mod, running into the same wall: Trying to extend the vegetation (trees, vines, bushes, flowers...) by adding frames to the existing stuff and coming up with new parts. BUT: Adding new parts fails when going into the .biome files.

    Code:
    /// Disclaimer: All codes are shortened
    
    {
    "name" : "forest",
    
    "surfaceParameters" : {
      "surfacePlaceables" : {
    
         "items" : [    <---------------------------- THAT SON OF A BASTARD!!!
            {
              "type" : "grass",
              "grasses" : [ "grass", "testflower", "testflower2", "testflower3" ...]
            },
            {
              "type" : "bush",
              "bushes" : [
                {
                  "name" : "testbush",
                  "baseHueShiftMax" : 180,
                  "modHueShiftMax" : 180
                }
              ]
            },
            {
              "type" : "tree",
              "treeStemList" : [ "birch", "cocoa", "fleshy", "grumpy", "metal", ...],
              "treeFoliageList" : [ "rose", "brains", "bubbles", "cloudy", ...]
            },
            {
              "mode" : "ceiling",
              "type" : "tree",
              "treeStemList" : [ "vine", "vine2", "vine3", "vine4" ],
              "treeFoliageList" : [ "flowery", "starry", "dreamy" ]  <-------  TRYING TO ADD A NEW VINE FOLIAGE HERE...
            }
    
          ] // /items
        } // /surfacePlacables
      } // /surfaceParameters
    }
    
    biomes/surface/forst/forest.surfacebiome
    
    So, as a suggestion for an unorthodox solution, would it work to replace those nested arrays with nested objects? It would be something like this:

    Code:
    {
    "name" : "forest",
    
    "surfaceParameters" : {
      "surfacePlaceables" : {
    
          "items" : {
            "capsulesObject" : {
              "type" : "object",
              "objectSets" : [
                {
                  "pool" : [ [0.35, "capsulesmall" ], [0.35, "capsulemed" ]...],
                  "parameters" : { }
                }
              ]
            },
            "flowerObject" : {
              "type" : "object",
              "objectSets" : [
                {
                  "pool" : [ [0.35, "flowerred" ], [0.35, "flowerblue" ]...],
                }
              ]
            },
            "rocksMicro" :{
              "type" : "microdungeon",
              "microdungeons" : [ "block1platforms", "loops", "spiralspikes"...]
            },
            "speciesEncounterMicro" : {
              "type" : "microdungeon",
              "microdungeons" : [ "randomencounter", "apexencounter", "avianencounter", ...]
    
            },
            "flowerGrass" : {
              "type" : "grass",
              "grasses" : [ "grass", "testflower", "testflower2", "testflower3", "testflower4", ...]
            },
            "bushesBush" : {
              "type" : "bush",
              "bushes" : [
                {
                  "name" : "testbush",
                  "baseHueShiftMax" : 180,
                  "modHueShiftMax" : 180
                }
              ]
            },
            "treeTree" : {
              "type" : "tree",
              "treeStemList" : [ "birch", "cocoa", "fleshy", "grumpy", "metal", ...],
              "treeFoliageList" : [ "rose", "brains", "bubbles", "cloudy", ...]
            },
            "vinesTree" : {
              "mode" : "ceiling",
              "type" : "tree",
              "treeStemList" : [ "vine", "vine2", "vine3", "vine4" ],
              "treeFoliageList" : [ "flowery", "starry", "dreamy" ]
            }
    
          } // /items
        } // /surfacePlacables
      } // /surfaceParameters
    }
    Is there any disadvange of objects towards arrays? Besides that one has to come up with funky names?

    ... And besides that a thousand files had to be changed midway in development... :seriously:

    I thought that, perhaps, those object conglomerates don't work when you have some kind of "pool" where one random thing gets picked. But IT DOES! In fact the vines nest their data in nice clean objects:

    Code:
    {
    "name" : "flowery",
    "shape" : "forestceiling",
    
    "crownLeaves" : { <-----------------  for some reason this is not an array....
        "crown1" : {
          "image" : "end1.png",
        },
        "crown2" : {
          "image" : "end2.png",
        }
    },
    
    "trunkLeaves" : {
        "middle1" : {
          "image" : "mid1.png",
        },
        "middle2" : {
          "image" : "mid2.png",
        }
    }
    
    }
    
    /// And I'm doing a merge in my mod with them:
    
    {
    "__merge": [],
    
    "baseLeaves" : {
        "anti_base3" : {
          "image" : "anti_base3.png",
        },
        "anti_base4" : {
          "image" : "anti_base4.png",
        }
    }
    
    plants/trees/forestceiling/foliage/flowery.modularfoliage
    
    This works like a charm, and as you can see, the names aren't even important!
    So I really wonder why stuff was put into the arrays in the first place. If it just had to be in an array, then I wonder why the vines are not... :confused:

    Another terrible example are the bushes:

    Code:
    {
    "name" : "shrub1",
    
    "mods" : [ "flowers", "growth", "thorns" ], <-------  Alright adding a new mod "berries" here is no problem, but...
    
    "shapes" : [           /////// MWAAAAHHH!
        {
          "base" : "base1.png",
          "mods" : {
            "flowers" : [ "flowers1.png", "" ],
            "growth" : [ "growth1.png", "" ],
            "thorns" : [ "thorns1.png", "" ]  <--------------  Adding a new mod "berries" HERE?! no way...
          }
        },
    
        {
          "base" : "base2.png",
          "mods" : {
            "flowers" : [ "flowers2.png", "" ],
            "growth" : [ "growth2.png", "" ],
            "thorns" : [ "thorns2.png", "" ]
          }
        }
    ]
    
    /// And analogue to the vines, why not store this data like this?!
    
    "shapes" : {
        "base1" : {
          "base" : "base1.png",
          "mods" : {
            "flowers" : [ "flowers1.png", "" ],
            "growth" : [ "growth1.png", "" ],
            "thorns" : [ "thorns1.png", "" ]
                                             <----- Merge-add a new thing here would be no problem
          }
        },
       "base2" :  {
          "base" : "base2.png",
          ...
        }
    }
    
    plants/bushes/ground/shrub1/shrub1.bush
    
    Too bad that this can't be done by some "Cleaning Mod" that replaces those files. It also has to be changed in the game code:
    VariantException: Improper conversion to VariantList from map in get("ThisWasAnArrayAndIsAnObjectNow")
     
    Last edited: Jan 7, 2014
    Karmos likes this.
  4. Annuschka

    Annuschka Big Damn Hero

    Mhh... The Starbound Modding Page states:

    And there are already third party mod managers that merge conflicting files in their own way.

    So maybe there will be a way to auto merge files without the __merge command, through a real mod manager system. There is still hope. :unsure:
     

Share This Page