Extensions to the __merge command (DEPRECATED)

Discussion in 'Starbound Modding' started by bartwe, Feb 8, 2014.

Thread Status:
Not open for further replies.
  1. bartwe

    bartwe Code Cowboy

    Code:
    {
       "__merge" : [],
       "defaultBlueprints" : {
          "tier1" : { "__merge" : [ "list", [
            [ "update",  { "item" : "bandage" },  { "item" : "nanowrap" } ] ,
            [ "delete",  { "item" : "torch" } ],
            [ "append",  { "item" : "peanutbutter" } ],
            [ "prepend",  { "item" : "timer" } ]
         ] ] }
       }
    }
    
    In the next patch there will be extended __merge support with list operations, to use this go to merge the list entry with a json map {} with a "__merge" entry containing the list merge commands.
    Currently "update", "delete", "append" and "prepend are supported.

    The "update" command causes a normal merge to happen with the found value and the provided second argument.

    The pattern used in "update" and "delete" is a softmatching value, meaning that a value matches if its equal, or in case of a map or list, that all entries in the mask have an equal in the value, in case of a map or list the original value may have fields not named in the mask.

    See also http://community.playstarbound.com/...iding-and-merging-config-files-in-mods.53775/
     
    Last edited: Feb 9, 2014
  2. The | Suit

    The | Suit Agent S. Forum Moderator

    Thanks - but what does update do?

    Edit -
    Thanks for describing each function out
     
    Last edited: Feb 8, 2014
  3. Game³oid

    Game³oid Big Damn Hero

    This would be amazing but what do the append and prepend mean? Or in other words explain the meanings of all of them!
     
  4. Game³oid

    Game³oid Big Damn Hero

    I think it means if you edit the code of bandage it will overwrite that...?
     
  5. The | Suit

    The | Suit Agent S. Forum Moderator

    Ya that is what I am wondering it means - but I rather be sure :p
    Append should be the same as adding to the element as last index
    Prepend adds item in the element as the first index

    I mean in general. Not a 100% sure in this case.
     
    Elate and Game³oid like this.
  6. Claith

    Claith Big Damn Hero

    Code:
    {
      "__merge" : [],
      "defaultBlueprints" : {
          "tier1" : {
            "__merge" : [ "list", [
            [ "update",  { "item" : "bandage" },  { "item" : "nanowrap" } ] ,
            [ "delete",  { "item" : "torch" } ],
            [ "append",  { "item" : "peanutbutter" } ],
            [ "prepend",  { "item" : "timer" } ]
            ] ] 
        }
      }
    }
    Using:

    Code:
    "defaultBlueprints" : {
      "tier1" : [
        { "item" : "mininglantern" },
        { "item" : "bandage" },
        { "item" : "torch" }
      ]
    }
    Okay, I'm trying to understand the hierarchy here.

    Just assuming it will work like this and "update" replaces a found value, the resulting merged file would be:

    Code:
    "defaultBlueprints" : {
      "tier1" : [
        { "item" : "timer" },
        { "item" : "mininglantern" },
        { "item" : "nanowrap" },
        { "item" : "peanutbutter" }
      ]
    }
    Correct?

    I'm trying to figure out if this can be used to append onto the oredistributions.configfunctions file, where I can add new ores to each tier. It is easy enough to add tiers previously, but that will not help. I really wish the ore tiers were assigned to a structure of some sort (i.e. "tier1", "tier2", ... , "tierx") or merging could use an index.

    Sitting here at the keyboard, trying to figure out how to continue and how to address my problem with an example, just running into dead ends.
    I can't directly access the indexes, so I guess I'll just have to remain incompatible with others for a while longer.

    Hopefully what I wrote above would be useful to someone. *grumble*
     
    Last edited: Feb 22, 2014
  7. The | Suit

    The | Suit Agent S. Forum Moderator

    @Claith
    No.
    Update replaces bandage with Nano Wrap
    Your example 2 and 3 - simply adds items to the Blueprints list - nothing else


    Edit - Misread post
     
    Last edited: Feb 22, 2014
  8. Claith

    Claith Big Damn Hero

    I did replace bandage with the nano wrap. The third code box would be the result of the example (first code box) merged onto the original (second code box).


    Either way, it doesn't seem that what I want to do is possible yet. I've downloaded other mods that work with the oredistribution file, and they don't merge either. I was hoping I was merely making it more complex that it needed to be, but I'm not alone it seems.
     
  9. The | Suit

    The | Suit Agent S. Forum Moderator

    Sorry your order of putting it just confused me.
    Yes that would be the "result" of the merge.
     
    Claith likes this.
  10. lornlynx

    lornlynx Cosmic Narwhal

    Is there any difference between append and adding it just without an explicit mergecommand for the tier?

    Also I have a small problem.
    I tried the merge feature with changing the input for the bandage recipe from plantfibre to one pixel. Usually I would do so this way:
    Code:
    {
      "__merge" : [["overwrite", "input"]],
      "input" : [
        { "item" : "money", "count" : 1 }
      ]
    }
    
    
    Which works fine.

    I thought that I want to try it now removing the plantfibre by hand and adding the pixels, instead of overwriting the whole input list, just to understand it better. I figured this should be how it's done:
    Code:
    {
      "__merge" : [],
     
      "input" : [
        "__merge" : [ "list", [
          [ "delete", { "item" : "plantfibre", "count" : 4 } ],
          [ "append", { "item" : "money", "count" : 1 } ]
        ] ]
      ]
    }
    
    
    But then the recipe doesn't appear at all. I guess I have made some mistakes with the list or maybe you can't delete lines which consist of more than one key:value. Anyone any ideas?
     
    Last edited: Mar 5, 2014
  11. Vaeux

    Vaeux Big Damn Hero

    You're specifying "input" as a list here, then giving it a map; Starbound probably logged this as invalid JSON (you should always check the log when something goes wrong). You probably want to use {} instead of [].
     
    lornlynx likes this.
  12. lornlynx

    lornlynx Cosmic Narwhal

    Ah, yes, you were correct, I have never bothered with JSON so this was new to me. Thanks!
     
  13. sayter

    sayter The Waste of Time

    okay.... Im still getting the hang of this. Can i USE append for ore distribution?

    Code:
    {
      "__merge" : [
      ["append", "surfaceOres"],
      ["append", "subsurfaceOres"],
      ["append", "deepsurfaceOres"],
      ["append", "depth1"],
      ["append", "depth2"],
      ["append", "depth3"]
    ],
      "surfaceOres" : [
        [0.5, [ [ "lead", 7.50], [ "sulphur", 0.50],[ "mascagnite", 0.40],[ "lazulite", 0.40],[ "magnesium", 0.40],[ "berlinite", 0.40] ] ],
        [1.5, [ [ "lead", 0.60], [ "sulphur", 0.40],[ "mascagnite", 0.40],[ "lazulite", 0.40],[ "magnesium", 0.40],[ "berlinite", 0.40] ] ]
    ]
    }
    
    its not the full snippet, since that would be pointless. When I use this as an append instead of an overwrite I get:


    Code:
    Error: Exception raised during Root finishInitialization: StoredFunctionException: Error parsing StoredConfigFunction descriptor
    caused by: MathException: Degenerate index values given in ParametricTable constructor
      009E38C4 starbound_opengl.exe
      00679CF1 starbound_opengl.exe
      0067B12A starbound_opengl.exe
      005016EB starbound_opengl.exe
      004041FC starbound_opengl.exe
      009A6D4C starbound_opengl.exe
      BaseThreadInitThunk
      RtlInitializeExceptionChain
      RtlInitializeExceptionChain
    
    Info: Shutting down Star::Root
    Error: StarException: An error occurred during loading: StoredFunctionException: Error parsing StoredConfigFunction descriptor
    caused by: MathException: Degenerate index values given in ParametricTable constructor
      009E38C4 starbound_opengl.exe
      00679CF1 starbound_opengl.exe
      0067B12A starbound_opengl.exe
      005016EB starbound_opengl.exe
      004041FC starbound_opengl.exe
      009A6D4C starbound_opengl.exe
      BaseThreadInitThunk
      RtlInitializeExceptionChain
      RtlInitializeExceptionChain
    
      0040466D starbound_opengl.exe
      004078A7 starbound_opengl.exe
      0040A4D4 starbound_opengl.exe
      0040814C starbound_opengl.exe
      004EDE61 starbound_opengl.exe
    


    hoping I can merge without needing to overwrite, so that i can be compatible with all ore editing mods without needing a gajillion compatibility patches.
     
  14. SunBlade

    SunBlade Void-Bound Voyager

    so, i take it we still can't add entries to lists inside of lists.

    which means merge still doesn't work on treasure pools, quest rewards or ore distributions.
     
  15. sayter

    sayter The Waste of Time

    Correct. Soon, I hope.
     
  16. prodamn

    prodamn Spaceman Spiff

    i wonder if i can merge or update files from files, like recipe1 includes the mergecommand for recipe2. as soon as recipe1 gets crafted it will update recipe2

    i was playing around already but i can't seem to specify a file for it to merge.
     
Thread Status:
Not open for further replies.

Share This Page