Tutorial Basic Patching Now With Path Guide [v1.9]

Discussion in 'Starbound Modding' started by The | Suit, Sep 19, 2014.

  1. Olxinos

    Olxinos Scruffy Nerf-Herder

    Simply rename [Filename] into titlemenumusic, and it will overwrite titlemenumusic.ogg.
    Usually, when it comes to replacing a music/song, you can also find the file referencing that specific song and patch it (i find it cleaner: replacing a vanilla file is also denying other mods to use/modify it) but i couldn't find that file.
     
    Last edited: Feb 15, 2015
  2. donpapillon

    donpapillon Scruffy Nerf-Herder

    Replacing the file with a file of a different name would involve patching specific assets that call it.

    If it's a single file, and you want to replace every instance of it, it would be better to simply replace the original by using the same name.
     
  3. PoeShmoe

    PoeShmoe Space Spelunker

    Alright, thanks you two.
     
  4. Wheee321

    Wheee321 Subatomic Cosmonaut

    Hello, maybe I'm a little dumb, but i can't add a new path

    { "op" : "add",
    "path" : "/statusControllerSettings/stats/-",
    "value" : "example1" }

    and I get an error. It's valid JSON. Help would be nice.

    edit:
    That:
    { "op" : "add", "path" : "/statusControllerSettings/stats/example1", "value" : {"baseValue" : 100.0}},
    works, but I would like to know, why the other doesn't.
     
    Last edited: Feb 16, 2015
  5. Olxinos

    Olxinos Scruffy Nerf-Herder

    The whole patch must also be enclosed by brackets ("[ ]", of course don't remove the curly brackets, they are necessary too), otherwise the patch seems fine.
     
  6. Wheee321

    Wheee321 Subatomic Cosmonaut

    Sorry, I just posted a fragment of tha patch. It actually is enclosed by brackets. Without that line the patch works fine.
     
  7. Olxinos

    Olxinos Scruffy Nerf-Herder

    Ah, I just checked player.config (you're patching player.config, aren't you?) stats is an object, not an array.
    So you probably want that instead:
    Code:
    [
      {
        "op" : "add",
        "path" : "/statusControllerSettings/stats/example1",
        "value" :
        {
          "baseValue":42.0
        }
      }
    ]
    Your patch would have worked if the structure of player.config resembled that:
    Code:
    {
      "statusControllerSettings":
      {
        "stats":
        [
          "item1",
          "item2",
          "item3"
        ]
      }
    }
    But it's more like that:
    Code:
    {
      "statusControllerSettings":
      {
        "stats":
        {
          "item1":null,
          "item2":null,
          "item3":null
        }
      }
    }
     
  8. Wheee321

    Wheee321 Subatomic Cosmonaut

    Thanks Olxinos, now it makes sense!
     
  9. Lazy Joe

    Lazy Joe Scruffy Nerf-Herder

    i cant get the syntax for more than one recipe right no matter what i tried, mine looks like this for now
    Code:
    [
      { "op" : "add", "path" : "/defaultBlueprints/tier1/-", "value" : [
        { "item" : "generatedsword", "count" : 1, "data" : { "definition" : "commonspear", "level" : 10 } },
        { "item" : "generatedsword", "count" : 1, "data" : { "definition" : "uncommonspear", "level" : 10 } }
      ]
      }
    ]
    When i only had the first line (commonspear), it was fine, as soon as i added a 2nd one, i added the [] after "value", and a comma after the first item line.

    game keeps crashing and refuses to start, can someone tell me where the error is? i just cant spot it
     
  10. The | Suit

    The | Suit Agent S. Forum Moderator

    ........>.<
    See giant red letters in end of tutorial.
     
  11. Lazy Joe

    Lazy Joe Scruffy Nerf-Herder

    you mean "add" doesnt work for current stable version?

    but for one line, it did work though D:
     
  12. The | Suit

    The | Suit Agent S. Forum Moderator

    You can only do 1 add at a time.- in an existing array.
    Code:
    [
      { "op" : "add", "path" : "/defaultBlueprints/tier1/-", "value" : x
    },
      { "op" : "add", "path" : "/defaultBlueprints/tier1/-", "value" : x
    }
    ]
    [/quote]
     
  13. Lazy Joe

    Lazy Joe Scruffy Nerf-Herder

    ah, thanks!
     
  14. OmnipotentEntity

    OmnipotentEntity Code Monkey Forum Administrator

    Thank you so much for this report. Sorry it took me so long to see it. I've corrected these problems and they should land in tonight's nightly (it just missed the stable released today by a few hours.)
     
    NerArth, Olxinos and The | Suit like this.
  15. Shadow Wolf TJC

    Shadow Wolf TJC Spaceman Spiff

    I've lately been seeing a similar kind of problem crop up when trying to do this:

    Source file for shuriken.projectile:
    Code:
    {
      "projectileName" : "shuriken",
      "frames" : "shuriken.png",
      "physics" : "hover",
      "animationCycle" : 0.1,
      "frameNumber" : 4,
      "power" : 20,
      "damageKindImage" : "icon.png",
      "speed" : 30,
      "timeToLive" : 5,
    
    
      "lightColor" : [255, 180, 0],
      "damageKind" : "default"
    }
    
    Source file for shuriken.projectile.patch, from a mod designed to make the shurikens retrievable after being thrown:
    Code:
    [
    {
      "op": "add",
      "path": "/actionOnReap/-",
      "value": {
        "action" : "item",
        "name" : "shuriken"
      }
    }
    ]
    When I try to run Starbound and use the shuriken item, it crashes. Apparently, it's because "actionOnReap" was undefined in the base shuriken.projectile file.

    However, I'm not comfortable with trying to make shuriken.projectile.patch like this either:
    Code:
    [
    {
      "op": "add",
      "path": "/actionOnReap",
      "value": [
        {
          "action" : "item",
          "name" : "shuriken"
        }
      ]
    }
    ]
    As JohnColburn said before, if I try to initialize an "actionOnReap" value when one already exists, even if another mod's shuriken.projectile.patch file already initialized it, then it crashes on startup.

    What I had to do in order to keep these problems from potentially happening is that I created what I'd call a "Compatability Bridger Mod" to initialize the "actionOnReap" value for one or more other mods, like so:
    Code:
    [
    {
      "op": "add",
      "path": "/actionOnReap",
      "value": []
    }
    ]
    Yes, it's an empty array, but if the mod is listed as being "required" in those other mods' .modinfo files, then the "Compatability Bridger Mod" would 1st initialize the "actionOnReap" array, then the other mods could then safely add in new values to that array. As an example of such a "Compatability Bridger Mod", I give you the LBoP Compatability Bridger mod, which was designed to apply this sort of principle to missing "learnBlueprintsOnPickup" arrays on items and objects that might need it, including material blocks and crafting stations.

    However, I'm personally hoping that future updates would get rid of the need for these kinds of mods, even if it means adding empty arrays to some default game files, though when it comes to defining anything other than an array, then I doubt that such "Compatability Bridger Mods" would be necessary, as "add" and "replace" do the job satisfactorily.
     
    NerArth likes this.
  16. OmnipotentEntity

    OmnipotentEntity Code Monkey Forum Administrator

    Unfortunately, the RFC does not give any utility to check whether or not a value exists without also checking the content of that value. And it provides no method of discerning between a failure missing value and a failure incorrect value. So any solution would necessarily have to be an extension of the RFC, which I'm a bit resistant to doing because I would love to retain the interoperability between starbound json patch files and the utilities that handle general json patch files.

    This is not to say we absolutely will not make extensions. (We already have, in fact.) But that we're reluctant to do so.
     
  17. The | Suit

    The | Suit Agent S. Forum Moderator

    CHANGELOG v1.9

    ADDED MULTILANGUAGE SUPPORT
    CLICK FOR TRANSLATION
     
  18. Mackinz

    Mackinz The Waste of Time

    Quick question. I'm updating an older mod (with the modmakers permission), which adds a ton of recipes to player.config. Do I have to "op" : "add" each item that is added, or can I do it all in a batch?
     
  19. The | Suit

    The | Suit Agent S. Forum Moderator

    You will need to add it one at a time.
    If you try to batch patch at the array level [ the only way to do it practically ] it will overwrite the entire array instead.
     
  20. Mackinz

    Mackinz The Waste of Time

    Sunnova...

    Alright, fine. :cry:
     

Share This Page