Overriding and merging config files in mods. (DEPRECATED)

Discussion in 'Starbound Modding' started by bartwe, Dec 16, 2013.

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

    EastBayWilly Title Not Found

    I don't understand the merging process at all. What do I put and where? Am I taking the full player.config and adding these merge lines into it somewhere? Am I making a new player.config that only contains the merge code?

    So far, modinfo and everything is easy to understand but I can't wrap my head around how this game merges player.configs.
     
  2. Nate McCloud

    Nate McCloud Existential Complex

    Does this work only for files ending in .config, or can it be used for recipes/objects/what have you, as well?
     
  3. gibbed

    gibbed Orbital Explorer

    I would assume it to function for any JSON files.
     
  4. Med

    Med Phantasmal Quasar

    Totally agree, but it's hard for me to say anything bad to the programmer who just promised me the perfect modding system. :rofl:
     
  5. Nate McCloud

    Nate McCloud Existential Complex

    Thanks for clearing that up! Though, if I wanted to overwrite/delete root-level objects (such as removing "printable" and adding "price" properties to crop seeds), what would I do? This?
    Code:
    {
      "__merge" : [ "delete", "printable" ],
      "price" : "1"
    }
     
    Last edited: Dec 17, 2013
  6. Heliostorm

    Heliostorm Phantasmal Quasar

    Will there be eventually be a way to automatically assign indexes for modded races? Because otherwise race mods will always have to be merged manually.
     
  7. Sabboth

    Sabboth Zero Gravity Genie

    Whether or not the next update makes any changes to how indices are assigned to races, I believe still a little bit of the battle is won. Now users of our race mods will have one less thing to worry about when trying to use multiple races, and our files will be much smaller, easier to read, and easier to navigate when they change id numbers and positions of buttons. I really hope that your push to remove assigning of indexes through the charcreation.config file and assigning of static indexes at all comes through, Kawa.
     
  8. TheSpaceMan

    TheSpaceMan Starship Captain

    Code:
    {
    // "__merge" : "nil", // sets file to nil, for some configs this will be treated asif the file was deleted
    "__merge" : [],
    "defaultBlueprints" : {
    "__merge" : [
    // ["delete", "tier1" ]
    [ "overwrite", "tier2" ]
    ],
    "tier1" : [ { "item" : "grapplinghook" } ],
    "tier2" : []
    }
    }
    //Human readable
    //Make sure we have no __merge file/data
    //set the data of merge to an array.
    //add the id of default blueprints to the merge array as a target for the merge, add the merge command to the byte array
    // comment out deletion of all tier1 gear
    // set command to overwrite tier2 gear
    // specify that tier1 merge should contain a grappling hook. (Add)
    // specify that tier2 should be emtpy (empty brackets []) //all tier2 equipment removed (see override above)

    As a dialog
    Execute
    Thanks starbound for reading my config file automaticly
    clear any old merge data that might be stored,
    create new mergedata array for me to store the following merge commands in
    add default blueprints to my mergedata commands
    add a merge command for blueprints depth.
    request overwrite for tier2
    define merge information tier1 should have an item grappelinghook
    define tier2 should be empty

    Execute

    End result, tier 2 tech dispears.
    tier 1 allows the creation of a grappeling hook.

    Add is not needed thats the default behavior if a parameter doesn't exist (merge)
    delete is necessary to remove a specific item.
    overwrite is necessary to add things while removing all other things in a category.

    Mayhaps maybe. Quite clear i would think.
     
    Kel^ and Med like this.
  9. Createse

    Createse Big Damn Hero

    A bit crude IMO but it does the job.
     
  10. Kawa

    Kawa Tiy's Beard

    "Crude", you say? I don't mean to disagree, but if you consider that "a bit crude", what would you have preferred?
     
  11. Leosky

    Leosky Void-Bound Voyager

    json isn't very good for this kind of things. JSON lightweight spec aren't made for such things, xml have xslt but make it ''''''complex'''''''' (heavy to read / handle). So this solution is pretty good as you keep the readability and aboard most of the usecase.
     
    Kawa likes this.
  12. gibbed

    gibbed Orbital Explorer

    Leosky and Kawa like this.
  13. Kawa

    Kawa Tiy's Beard

    Hold up. Was that an attempt to use MediaWiki markup on a messageboard? Now I've seen it all.
     
    Leosky likes this.
  14. Leosky

    Leosky Void-Bound Voyager

    Code:
    {
      "__merge" : [
        [ "delete", "foo" ]
        [ "overwrite", "bar" ]
      ],
      "bar" : [ "after" ]
    }
    hum, missing ',' after the delete array !

    but, your example isn't very clear about multiple delete,

    Code:
    {
      "__merge" : [
       [ "delete", "foo" ],
       [ "delete", "fooz" ],
        [ "overwrite", "bar" ]
      ],
      "bar" : [ "after" ]
    }
    ? or something else ?
    no ! i just wanted to moderate the complex adjective ! (longer to learn / read)
     
  15. gibbed

    gibbed Orbital Explorer

    Fixed, thanks.

    That is correct, I'll update it to add a new delete entry as an example.
     
  16. Med

    Med Phantasmal Quasar

    Nice find! :laugh: It definitely clears some things up. For example, we better be careful not to leave duplicate entries in our lists, because they will indeed be duplicated. Also, no difference between "delete" and "overwrite" is very helpful.

    But my concern is with "moving" default recipes in player.config to latter tiers. Although he says deletion applies to "everything", I still question this syntax:

    player.config
    {
    "__merge" : [],
    "defaultBlueprints" : {

    "tier1" : [
    // Delete Platinum pick from tier 1.
    "__merge" : [ ["delete", { "item" : "platinumpickaxe" } ] ]

    // Still in "tier1", add new recipes.
    { "item" : "beamaxe_copper" },
    { "item" : "beamaxe_silver" },
    ]

    // Add Platinum pick to Tier 2.

    "tier2" : [
    { "item" : "platinumpickaxe" }
    ]
    }
    }
     
  17. Leosky

    Leosky Void-Bound Voyager

    hum, i'm still a bit confuse about deleting things. In 'Player.config', blueprints are written like : '{"item" : "steelaxe"}'
    so here how we will handle that ?

    Code:
    {
      "__merge" : [
      [ "delete", {"item" : "steelaxe"} ],
      [ "delete", "fooz" ],
        [ "overwrite", "bar" ]
      ],
      "bar" : [ "after" ]
    }
    ?

    and, in this context, i don't think delete and ovewrite are very relevant in "__merge" :eek:.
     
  18. gibbed

    gibbed Orbital Explorer

    Firstly, that's not valid JSON. Secondly I would assume that not to be something that will work.

    Currently I don't think you can do that. As for __merge name, it's just a keyword/magic name, it doesn't indicate the operation actually happening. I've suggested ways to delete items from lists using map key value pairs as you guys do want, though it's not currently supported (I think).
     
  19. Leosky

    Leosky Void-Bound Voyager

    hum, so it's still a problem in this case :>

    delete should work with a xpath like syntaxe to select elements. Add simple case like this isn't very complicated, but it will be very laborious with multimapped elements to target the first map.

    In this case:

    Code:
    {
        "itemBundle" : {
            "item" : {
                "proprety1" : [
                    { "value1": "a" },
                    { "value2" : "z" }
                ],
                "proprety2" : [
                    { "value1": "e" },
                    { "value2" : "r" }
                ],
                "proprety3" : [
                    { "value1": "t" },
                    { "value2" : "y" }
                ],
                "proprety4" : [
                    { "value1": "u" },
                    { "value2" : "i" }
                ]
            },
            "item" : {
                "proprety1" : [
                    { "value1": "o" },
                    { "value2" : "p" }
                ],
                "proprety2" : [
                    { "value1": "p" },
                    { "value2" : "q" }
                ],
                "proprety3" : [
                    { "value1": "s" },
                    { "value2" : "d" }
                ],
                "proprety4" : [
                    { "value1": "f" },
                    { "value2" : "g" }
                ]
            },
            "item" : {
                "proprety1" : [
                    { "value1": "h" },
                    { "value2" : "j" }
                ],
                "proprety2" : [
                    { "value1": "k" },
                    { "value2" : "l" }
                ],
                "proprety3" : [
                    { "value1": "m" },
                    { "value2" : "w" }
                ],
                "proprety4" : [
                    { "value1": "x" },
                    { "value2" : "c" }
                ]
            }
        }
    }
    deleting a specific item, will be tricky (and i didn't choose a complex example as 'property1' change very time).

    Code:
    {
        "__merge" : ["delete" , {"item" : {"proprety1" : {"value" : "a"}}}]
    }
    here could target the elements item with 'property1' having a 'value' equals to 'a'.

    and this could be a nicer syntax ?

    Code:
    {
        "__delete" : [
            {"item" : {"proprety1" : {"value1" : "a"}}},
            {"item" : {"proprety2" : {"value2" : "q"}}},
            {"item" : {"proprety4" : {"value2" : "g"}}}
        ]
    }
     
  20. Med

    Med Phantasmal Quasar

    So, you've got "proprety1" which is a list of pairs. One of those pairs is {"value" : "a"} and you want to delete it. Do this:

    Code:
    {
        "__merge" : [],
        "itemBundle" : {
            "item" : {
                "__merge" : [ 
                    [ "overwrite" ,"proprety1" ]
                ]
                "proprety1" : [
                    { "value2" : "z" }
                ]
            }
        }
    }
    
    Your situation is easy because proprety1 doesn't have very many items and you probably aren't using any other mods that want to change proprety1.

    But the list of blueprints the player starts with in player.config is massive, and if I delete some by overwriting the entire list, I am in danger of overwriting other mod merges that were loaded before my mod, and being overwritten by a latter mod if they use the same overwrite method to delete a few recipes.
     
Thread Status:
Not open for further replies.

Share This Page