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. danks_

    danks_ Existential Complex

    So let's say that for automation's sake I use a file that looks like one of these, will they work? (I know line breaks are out of place, kind of intended)

    Code:
    { "__merge" : [],
    "defaultBlueprints" : {
    "__merge" : [],
    "tier1" : [
    { "item" : "1" }
    ], "tier2" : [
    { "item" : "2" }
    ], "tier3" : [
    { "item" : "3" }
    ], "tier4" : [
    { "item" : "4" }
    ], "portable3dprinter" : [
    { "item" : "5" }
    ] } }
    -

    Code:
    { "__merge" : [],
    "defaultBlueprints" : {
    "__merge" : [],
    "tier1" : [
    { "item" : "item1" }
    ], "tier2" : [], "tier3" : [], "tier4" : [], "portable3dprinter" : [
    { "item" : "item2" }
    ] } }
    -

    Code:
    { "__merge" : [],
    "defaultBlueprints" : {
    "__merge" : [],
    "tier1" : [], "tier2" : [], "tier3" : [
    { "item" : "thisitem" }
    ], "tier4" : [], "portable3dprinter" : [] } }
     
  2. Nate McCloud

    Nate McCloud Existential Complex

    I...think so? Try it and see. Since you are only adding recipes, not altering items, if something goes wrong, you should be able to correct it without losing any items.
     
  3. Target-san

    Target-san Subatomic Cosmonaut

    My humble suggestion as a programmer with some experience: this is definitely a bad design. Why? Because you can mess others work too easily. Methods for override should definitely exist, _but_ they should be accessible only in a hard and explicit way. As I understand, current default behavior is overriding. I'd propose to use "merge" as default behavior. Thus, by simply declaring list of recipes, modders won't mess anyone's work. My next suggestion is to _remove_ override/drop functionality from config and expose it via Lua API, so thils logic is executed from init script.
    In short: default behavior is _safe_ and _easy_ to achieve, and advanced logic _is_not_ easy to achieve.
     
  4. CrownFox

    CrownFox Subatomic Cosmonaut

    That would be silly. If you're going to use two folders to load your mod, then you shouldn't use overwrite to delete a couple recipes, you should just use delete.
     
  5. Med

    Med Phantasmal Quasar

    Overwrite and delete do the same thing. But yes, using "delete" would be more readable.
     
  6. Woden

    Woden Twenty-three is number one

    Argh, I'm about at my wit's end trying to figure out this new system.

    As a test, I've tried super-charging the Matter Manipulator so that I could quickly see if it's working or not. Here's the code I have from that mod file (which is in mods/testing/assets/beamaxe.beamaxe):

    Code:
    {
        "__merge" : [],
        "fireTime" : 0.01,
        "blockRadius" : 4
    }
    
    However, that causes the following error in Starbound.log:

    Code:
    Error: Exception caught in Thread Async root loader: ItemException: Could not load item asset /beamaxe.beamaxe
    caused by: VariantException: No such key in Variant::get("itemName")
      007DFD94 (E:/Steamworks/Starbound/git/starbound/source/core/StarVariant.hpp:14)
      0058CEEC (E:/Steamworks/Starbound/git/starbound/source/game/StarItemDatabase.cpp:281)
      004DD71F (E:/Steamworks/Starbound/git/starbound/source/game/StarRoot.cpp:168)
      004016D8 (E:/Steamworks/Starbound/git/starbound/source/client/StarClientApplication.cpp:302)
      009681DC (E:/Steamworks/Starbound/git/starbound/source/core/StarThread_windows.cpp:74)
      7537336A
      77729F72
      77729F45


    Furthermore, trying to start the game gives the following exception:

    Code:
    StarException: No player species defined. 0058F473
    (E:/Steamworks/Starbound/git/starbound/source/game/StarSpeciesDatabase.cpp:69) 00444B12
    (E:/Steamworks/Starbound/git/starbound/source/frontend/StarCharCreation.cpp:165) 00446F97
    (E:/Steamworks/Starbound/git/starbound/source/frontend/StarCharCreation.cpp:120) 004487E5
    (E:/Steamworks/Starbound/git/starbound/source/frontend/StarCharCreation.cpp:91) 0041CDFC
    (E:/Steamworks/Starbound/git/starbound/source/frontend/StarTitle.cpp:135) 0041D2FB
    (E:/Steamworks/Starbound/git/starbound/source/frontend/StarTitle.cpp:28)
    ... (3) 0040A214
    (E:/Steamworks/Starbound/git/starbound/source/application/StarApplicationBase.cpp:199) 00407C30
    (E:/Steamworks/Starbound/git/starbound/source/client/main.cpp:48) 004DBBD1
    (c:\SDL-1.2.15/./src/main/win32/SDL_win32_main.c:318)


    Any help in figuring out what I'm doing wrong would be greatly appreciated.
     
  7. Med

    Med Phantasmal Quasar

    Wrong location. Get rid of the assets folder. In order to merge with the original beamaxe, your file has to be in the same spot it would normally be in under assets, so: mods/testing/items/tools/beamaxe.beamaxe

    Also make sure you have testing/testing.modinfo or it wont load at all.

    That will make it work. :giggle:

    EDIT: Try looking at a bunch of other people's mods, such as a Beamaxe mod, to learn how they are doing it.
     
    Darcalus and Woden like this.
  8. Woden

    Woden Twenty-three is number one

    Good to know. I assumed it was matching them up based on item names or something. In retrospect, it seems rather obvious that it would have to follow the hierarchy to know what's being modified.

    Already have one. I would have thought that was obvious, since it was loading enough to cause problems. ;)

    It didn't. Even using the same folder hierarchy as the assets folder, it's still giving the same crashes / log entries. :(

    Error: Exception caught in Thread Async root loader: ItemException: Could not load item asset /testing/items/tools/beamaxe.beamaxe
    caused by: VariantException: No such key in Variant::get("itemName")

    Mod folder is "testing", the .modinfo file has "[.]" for the directory path, and the file is at "mods/testing/items/tools/beamaxe.beamaxe" now.

    I have been looking... I can't seem to find many examples that are using this new merge syntax, though, and the few that are don't appear to be using it any differently than my example. Heck, before writing this reply up, I just browsed the mod section and downloaded a half-dozen or so more mods that appeared to be changing items (rather than just adding new stuff), and only one of them was using the __merge syntax... and I can't for the life of me spot what I'm doing wrong based on that.
     
  9. Karull

    Karull Big Damn Hero

    EDIT: Actually doing it simply like this worked fine for me...
    Code:
    {
      "__merge" : [],
      "fireTime" : 0.01,
      "blockRadius" : 4
    }
    I just copied the beamaxe.beamaxe from the starbound folder, set up the correct file path of mods/nameofmod/items/tools/ and pasted it in the tools folder. opened the .beamaxe file and put that code in, no errors worked perfectly fine.
     
    Last edited: Dec 27, 2013
    Woden likes this.
  10. Woden

    Woden Twenty-three is number one

    Okay, this was my problem. I mistakenly had it as mods / testing / testing / items / tools. Somehow, I failed to notice that goof-up earlier. Shifting things up so that the second testing folder was gone made it start working without a problem. Thanks for the help, guys!
     
  11. Monkeybiscuit

    Monkeybiscuit Phantasmal Quasar

    The merge system has defeated my tiny brain also. Can anyone provide the code needed for a simple config file merge when adding a mod with for example a single recipe? I'm not really doing any overrides, just adding files with my mods.
     
  12. Kawa

    Kawa Tiy's Beard

    In mods/YourMod/player.config:
    Code:
    {
        "__merge" : [],
        "defaultBlueprints" : {
            "tier1" : [
                { "item" : "myitem" }
            ]
        }
    }
    This will allow any newly-made player character access to myitem in whatever crafting system that item is set up to appear. Where that is depends on myitem.recipe, I hope you already know. Which means the above and a myitem.recipe is the only thing you'd need to do to have a single item mod work.
     
    Monkeybiscuit likes this.
  13. Woden

    Woden Twenty-three is number one

    How would you go about adding an item to the default Ship Locker inventory? I know which file to modify, but I'm guessing that the nested arrays used in so many of the treasure pool files are going to be rather problematic to modify as things currently stand.

    Is the current method simply to completely override the treasure pool that you need to add to?
     
  14. Kawa

    Kawa Tiy's Beard

    Seems so.
     
  15. Monkeybiscuit

    Monkeybiscuit Phantasmal Quasar

    I was going to award you a page full of the worship emoticon, but those old ones are gone now. So I shall send a few monkeys your way!

    :monkey::monkey::monkey::monkey::monkey::monkey:
     
  16. Kawa

    Kawa Tiy's Beard

    If you're gonna worship someone, worship the developers for giving us __merge in the first place.
     
  17. KoreRekon

    KoreRekon Big Damn Hero

    I wasn't messing with treasurepool, but I had the exact same problem. Thank you for helping me fix it.
     
  18. Monomer

    Monomer 2.7182818284590...

    Has anyone tried to do this with celestial.config yet? I've been reading the posts here but can't seem to get a merge to work properly when trying to add a biome to the "unlockedBiomes" field for each sector in celestial.config. For example, here is the vanilla code that I want to add to.

    Code:
    "sectors" : [
        {
          "id" : "alpha",
          "name" : "Alpha Sector",
          "sectorSeed" : 71707887027,
          "prefix" : "Alpha",
          "sectorSymbol" : "/celestial/sector/1.png",
          "hueShift" : -30,
    
          "worldParameters" : {
            "threatLevel" : [1, 1],
            "unlockedBiomes" : [ "arid", "desert", "forest", "snow", "moon" , "barren", "asteroidfield"]
          }
        },
    I'd like to add "wasteland" to the unlockedBiomes field in that example (as well as for the other sectors), but keep getting parse crashes. Any help would be appreciated.
     
  19. Kawa

    Kawa Tiy's Beard

    Even if you got the syntax right, you'd probably end up defining an all new sector with a whole lot of missing data instead of adding something to Sector Alpha's unlockedBiomes list. It seems to be one of those structures, like NPC guard warning dialogues, that __merge can't handle.
     
  20. simplex

    simplex Astral Cartographer

    The only way to change things nested in lists (arrays, "stuff between square brackets" or however you want to call it) is by replacing the entire list. Unfortunately.
     
    Woden and ahappydude like this.
Thread Status:
Not open for further replies.

Share This Page