Modding Help Problems with "__merge" in default.treasurepool

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

  1. Dr. Toros

    Dr. Toros Existential Complex

    What I'm trying to do is add "[ "ApexAgility" , 1]" to

    Code:
    "apexStarterTreasure" : [
        [0, {
            "fill" : [
              "beamaxe",
              "flashlight",
              [ "torch", 10],
              [ "bananaseed", 3],
              [ "wheatseed", 3],
              [ "apexstarter", 1]
            ],
            "levelVariance" : [0, 0],
            "allowDuplication" : false
          } ]
      ],
    Using the "__merge" command

    I think the part that is throwing me for a loop is the

    Code:
    [0, {
    section.

    Anyone have any idea what the correct syntax is? I keep getting duplicate "apexStarterTreasure" errors.
     
  2. Karull

    Karull Big Damn Hero

    try this:
    Code:
    {
    "__merge" : [],
    "apexStarterTreasure" : [
        [0, {
            "fill" : [
              [ "ApexAgility" , 1]
            ]
          } ]
      ]
    }
    Can't gurantee it'll work, I'm just starting to get into coding so this is good practice though.
     
    Dr. Toros likes this.
  3. Dr. Toros

    Dr. Toros Existential Complex

    Interesting. What it looks like it did is overwrote the whole entry, so in the ship's locker, I only find "ApexAgility".

    It did load and get my item in though, so that's progress!
     
  4. Karull

    Karull Big Damn Hero

    hmm, weird. You know, you can just make a brand new treasure file and just paste it normally however you want. It won't override anything either.
     
  5. Dr. Toros

    Dr. Toros Existential Complex

    Tried this, game didn't like duplicate entries of "apexStarterTreasure"
     
  6. Sabboth

    Sabboth Zero Gravity Genie

    I believe the reason why you're getting duplicate starter treasures is because:
    Code:
    {
    "__merge" : [],
    "apexStarterTreasure" : [
        [0, {
            "fill" : [
              [ "ApexAgility" , 1]
            ]
          } ]
      ]
    }
    If you notice the bracket after "apexStarterTreasure" : that denotes a list. So if you call "__merge" before the list "apexStarterTreasure" it's actually creating a second entry to the list rather than merging together what was already in the list.

    I had tried adding "__merge" after the first bracket and before [0, { but that caused a problem. I'm not entirely sure what to do after that but hopefully that points you in a better direction.
     
    Dr. Toros likes this.
  7. Karull

    Karull Big Damn Hero

    You're right, I was totally thinking of doing it for a custom race lol.

    This should work:
    Code:
    {
      "__merge" : [],
      "apexStarterTreasure" : [
        [0, {
            "fill" : [
              "beamaxe",
              "flashlight",
              [ "torch", 10],
              [ "bananaseed", 3],
              [ "wheatseed", 3],
              [ "apexstarter", 1],
              [ "ApexAgility" , 1]
            ],
            "levelVariance" : [0, 0],
            "allowDuplication" : false
          } ]
      ]
    }
     
    Dr. Toros likes this.
  8. Annuschka

    Annuschka Big Damn Hero

    I have outlined the same problem here. Sadly, I don't have a solution. I'll keep an eye on this discussion in case you find something...
     
    Dr. Toros likes this.
  9. Dr. Toros

    Dr. Toros Existential Complex

    Thanks for this. I eventually came to the same conclusion you did. At least by simply replacing the list I'm trying to merge, I can still improve compatability by overriding all of default.treasurepools, just the starting inventories. Not perfect, but better.
     
  10. Ominus

    Ominus Void-Bound Voyager

    The merge function only works in config files, it will not work on treasurepool, or any other files, but that will hopefully change to allow more compatibility.
     
  11. Annuschka

    Annuschka Big Damn Hero

    And this is wrong. It works perfectly in all files that use JSON, regardless of their filename-extension.
     
    Spacedino likes this.
  12. Ominus

    Ominus Void-Bound Voyager

    OH YEAH!? .... didn't know that, I'm new to JSON, so merging works on almost everything modable, except the problems listed here and the other topic? Atleast as I understand so far from reading both topics.

    The __merge topic name made me think it only worked in config files.:oops:
     
  13. bartwe

    bartwe Code Cowboy

    merging with lists/arrays is not currently possible sadly, only appending and replacing.
     
  14. Annuschka

    Annuschka Big Damn Hero

    Maybe it would be a solution to change the structure of the critical configs, avoiding nested arrays. I know, this will break a few old mods, but...

    Code:
    "genders" : {
      "male" : {
          "image" : "/interface/title/plantmaleicon.png",
          "characterImage" : "/interface/title/plantmale.png",
          "hair" : [ "1", "2", "3" ],
          "shirt" : [ "floranfurnivourchest", "floranhunterchest"],
          ...
      },
      "female" :  {
          "image" : "/interface/title/plantfemaleicon.png",
          "characterImage" : "/interface/title/plantfemale.png",
          "hair" : [ "1", "2", "3" ],
          "shirt" : [ "floranfurnivourchest", "floranhunterchest" ],
          ...
      }
    }
    Instead of

    Code:
    "genders" : [
      {
        "name" : "male",
        ...
      },
      {
        "name" : "female",
        ...
      }
    ]

    It would be easier to edit nested stuff like this, wouldn't it?
     
  15. Kyrosiris

    Kyrosiris Scruffy Nerf-Herder

    How does appending work, and will multiple unique attempts to append conflict?
     
  16. Annuschka

    Annuschka Big Damn Hero

    Appending: "__merge" : [] without any further commands appends new values at the end of arrays. "multiple unique"? Do you mean if two mods append to the same array? They will be added one after another, no conflicts.
    It seems that mods are loaded in alphabetical order: First A then B, with B overwriting stuff from A if they do not merge properly.

    I hope this helps.

    Example:

    Code:
    /// Original data
    "foo" : ["1", "2", "3"]
    
    /// Mod A:
    "__merge" : [],
    "foo" : ["four"]
    
    /// Then Mod B:
    "__merge" : [],
    "foo" : ["bar", "lol"]
    
    /// Result:
    "foo" : ["1", "2", "3", "four", "bar", "lol"]
    
    /// But if we have a mod C that overwrites stuff...
    "__merge" : [
      ["overwrite", "foo"]
    ],
    "foo" : ["rofl"]
    
    /// foo will be just "rofl"
    
     
  17. Papaya_freak

    Papaya_freak Scruffy Nerf-Herder

    Okay, so here's how I thought about working around this problem you have.

    Create a new starter droppool for the race. something like "apexStarterTreasureTouHou". obviously merge that in the
    mod folder file for compatibility.
    Then try and use merge in dropship.structure.

    Code:
        {
          "value" : [0, 255, 0, 255],
          "foregroundBlock" : false,
          "backgroundBlock" : true,
          "backgroundMat" : "apexshipwall",
          "object" : "apexshiplocker",
          "objectParameters" : {
            "treasurePools" : [  "apexStarterTreasureTouHou" ],
            "level" : 1,
            "unbreakable" : true
          }
        },
    so that with your mod installed, the starter pack is the new one. i gave it a quick to ro merge but was not working and i'm
    tired so yeh.
     
  18. Papaya_freak

    Papaya_freak Scruffy Nerf-Herder

    I also tried to see if
    "treasurePools" : [ "apexStarterTreasure", "apexStarterTreasureTouHou" ],

    would work, but it did not. It only gave the second item. It does say treasurepools plural so wishful thinking there.
     
  19. abarilov

    abarilov Void-Bound Voyager

    hey guys, a good workaround is to add a modified .structure file from /ships/<<RACE>>/dropship.structure and change the starter items, and append a new list to default.treasurepools. That how I got custom items into my modded ship, but I see if you dont want to have to add them to every race individually?
     

Share This Page