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

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

  1. lazarus78

    lazarus78 The Waste of Time

    I love how you guys are so open with explaining the innards of your game. It really helps us understand how it works and improves our ability to report bug as well as create mods.
     
    Nate McCloud likes this.
  2. Nate McCloud

    Nate McCloud Existential Complex

    True, but if I use includes, doesn't that mean that the mod is loaded immediately after the "included" mod, so that a given item is guaranteed to be in a certain position in an array?
     
  3. OmnipotentEntity

    OmnipotentEntity Code Monkey Forum Administrator

    No, because if two mods load the same include then it will be loaded immediately before whichever mod tries to load first. Also if a mod loads both includes and requires then the requires are loaded after the includes.

    For clarity, here is the mod sorting code in use in the current revision. I don't expect it to change (though it might).

    http://pastebin.com/a3m6hHp2 (the forums eats the indentation)
     
  4. The | Suit

    The | Suit Agent S. Forum Moderator

    Essentially Omni is stating the Scenario

    Mod A
    Mod B and C - both have Mod A includes.
    Where mod B is the predicted mod, where Mod C is an unknown mod which also references mod A.


    Then you get into a tricky situation because it could be either or one of those.
    You really can't predict ahead of time what the users will download and what other mod interactions are.
    Which is one reason I always advocate to add to the bottom of a list instead of top. That way at least the vanilla order is maintained, so that (vanilla) order will almost always will be predictable.

    Making a patch for a mod which patches a vanilla file is literally shooting blind.
    Unfortunately without a mod order sorter like in Bethesda there is no safe way to do it

    ==
    Which is kind of funny - because if you ever thought this stuff is complicated.
    Imagine the devs dealing with trying to fix the game for PC's which has a few million combinations of hardware and software [ OS's ] in the mix.
    Pillars of Eternity Dev's had even another monkey wrench language settings in Linux which changed gold calculation by a factor of a 1000 because the posistion in german for "." (period) ended up a "," (comma) in a german linux distro.
     
    Last edited: Apr 22, 2015
  5. Nate McCloud

    Nate McCloud Existential Complex

    This all sounds very complicated...I think I'll just stick with writing independent mods.
     
  6. Zizzy

    Zizzy Void-Bound Voyager

    does anyone know the new way to do nocollision with the physics.config? this is what I've got but it's incorrect
    [
    "nocollision" : {
    "gravityMultiplier" : 0.0,
    "bounceFactor" : 1.0,
    "maxMovementPerStep" : 0.4,
    "groundSlideMovementEnabled" : false,
    "collisionPoly" : [],
    "ignorePlatformCollision" : true,
    "groundFriction" : 0,
    "airFriction" : 0,
    "liquidFriction" : 0,
    "speedLimit" : null
    }
    ]
     
  7. The | Suit

    The | Suit Agent S. Forum Moderator

    It would be a good idea to use [code] [/code] tags. When posting code.
    That should work - are you sure your patch code is not wrong?
     
  8. Zizzy

    Zizzy Void-Bound Voyager

    thx for taking time to reply but i actually already figured out the issue with the patch tester link
     
  9. NerArth

    NerArth Pangalactic Porcupine

    I was having a similar issue.

    The base file I was trying to patch was cobblestone.matitem:
    Code:
    {
      "itemName" : "cobblestonematerial",
      "rarity" : "Common",
      "inventoryIcon" : "cobblestone.png",
      "dropCollision" : [-2.5, -2.0, 2.5, 2.0],
      "shortdescription" : "Cobblestone",
      "description" : "Hard stones, smooth to the touch.",
      "glitchdescription" : "Statement. Cobblestones.",
      "florandescription" : "Cobblessstone.",
    
      "materialId" : 3
    }
    

    Originally my code was:
    Code:
    [
      {
      "op":"add",
      "path":"/learnBlueprintsOnPickup/-",
      "value":"masonrytable"
      }
    ]
    
    Which would not get parsed correctly using the tester. However, based on what you'd posted, I changed the code to:
    Code:
    [
    
    
      {
      "op":"add",
      "path":"/learnBlueprintsOnPickup",
      "value":[]
      },
    
      {
      "op":"add",
      "path":"/learnBlueprintsOnPickup/-",
      "value":"masonrytable"
      }
    
    
    ]
    
    And this worked. It was a bit of a nuisance, as I have trouble as it is understanding the patching system, as I've not used it before really, even when it was added.[DOUBLEPOST=1433247163][/DOUBLEPOST]Also, couldn't this thread be stickied?*
     
    Last edited: Jun 3, 2015
  10. The | Suit

    The | Suit Agent S. Forum Moderator

    Just combine the two together.

    Code:
    [
      {
      "op":"add",
      "path":"/learnBlueprintsOnPickup",
      "value": [ "masonrytable" ]
      }
    ]
    You only need to use /- if you are adding to an existing array. Which is why it wasn't working for you earlier.

    ==

    As for making it a sticky it is already in the modding guides sticky. That is more than enough.
     
    Last edited: Jun 2, 2015
  11. NerArth

    NerArth Pangalactic Porcupine

    Sorry, I did look in that thread but must have missed it, I'll have a look again in a minute.

    Thanks, I tried something similar but I think hadn't used the brackets properly at some point, so that must be where I got confused.
     
  12. Wulf_Oman

    Wulf_Oman Existential Complex

    I think he said NOT stickied? Dunno why you'd want to do that though
     
  13. Lupus Alifer

    Lupus Alifer Void-Bound Voyager

    So we can't simply replace a whole JSON if we are making bulk changes anymore???
     
  14. The | Suit

    The | Suit Agent S. Forum Moderator

    If you simply replace the whole JSON - you are making a dirty edit most likely.
    Which means you are making a mod which will be highly incompatible with other mods.

    If you are making the mod for personal use, its up to you.
    If you are planning on distributing here though, you need to use patching.
     
  15. Lupus Alifer

    Lupus Alifer Void-Bound Voyager

    That's a good point! I didn't think about compatibility. Thank you moderator!
     
  16. Taiine

    Taiine Pangalactic Porcupine

    I'm having an issue with one of my mods. I'm trying to add a custom ore to the moon yet it's not spawning at all. I tested the ore spawns on normal worlds and it does spawn just fine. I'm thinking I'm getting the path wrong for the moon layers.
    "path" : "/moonores/0/1/-",
    and
    "path" : "/moondeepores/0/1/-",
    is what I'm using. Is this right or?
    Or is there anything extra I need to do to get it to spawn on the moon? I also tried to ass a small amount of coal to the moons as well with no luck
     
  17. The | Suit

    The | Suit Agent S. Forum Moderator


    Code:
    [
        {
            "op":"add",
            "path":"/moonores/0/1/-",
            "value": ["test", 4]
        }
    ]
    It is always good to use a JSON patcher to see if it is right or not
    json-schema-validator.herokuapp.com/jsonpatch.jsp
     
  18. Taiine

    Taiine Pangalactic Porcupine

    ..........why don't people read? I swear it is not that hard to read. Bad when it's a moderator. >.< I'll say right now I get really REALLY sick and tierd of having to repeat myself because people don't freaking READ. Please stop skimming and assuming and read what people freaking say! Sorry if this sounds rude or such but I see this happen all the freaking time to myself and other people!


    So round 2. I'm not talking about rather or not my json is correct or not. I already said I tested it first on
    "path" : "/surfaceOres/0/1/-",
    and it worked FINE. Spawning the ore on the worlds surfaces.


    it's adding it to the MOON where I want it that its not spawning.
    Like I said I think the PATH /moonores/0/1/- might not be the right path to make it spawn.

    So, I never asked is the json right or not. I'm asking is the PATH FOR THE MOON if it is right or not. A check to see if json is valid or not isn't going to tell me that.


    So sense it's going to come up, yes I used that site, it gives the exact same error each time rather the ore works or not.
    "message" : "failed to apply patch",
    "exceptionClass" : "com.github.fge.jsonpatch.JsonPatchException",
    "exceptionMessage" : "parent of node to add does not exist",
    "info" : "other messages follow (if any)"
    Even when it worked fine. Shoot it throws the exact same error when I plop in custom ores from other mods. Shows the exact error no matter what path you toss in valid or not.

    So yes, this don't help me, and isn't at all what I asked for.

    So to make 100% clear for the people who don't want to read:



    [
    {
    "op":"add",
    "path":"/surfaceOres/0/1/-",
    "value": ["erechusshard", 1.20]
    }
    ]

    THAT WORKS 100% FINE.


    [
    {
    "op":"add",
    "path":"/moonores/0/1/-",
    "value": ["erechusshard", 1.20]
    }
    ]


    DOES NOT WORK. I think the PATH IS WRONG. That or there is something extra to make ores spawn on the moon as I cant even get coal to spawn when I use a simple replace in my ore rebalance mod thats already out.
     
    Last edited: Jul 30, 2015
  19. The | Suit

    The | Suit Agent S. Forum Moderator

    All you really need to check is moon.biome and go to the heading ores
    to see which path the surface biome uses.

    Then go to moonunderground.biome to again confirm which ores it takes it from
    .
    If both match -- just remove all the other ores from moon and only have yours.
    Visit an unvisited moon and see if it works.

    If it does you were just getting poor range.
     
  20. Taiine

    Taiine Pangalactic Porcupine

    .. the path is moonores and moondeepores, I know the path is moonores and moondeepores as it's the path listed in the oredistributions.configfunctions file. I don't know if the /0/1/- is right or not. even with out it nothing spawns.
    I see nothing in the biome codes that would effect or limit what ores can spawn.

    I've even done
    {
    "op" : "replace",
    "path" : "/moonores",
    "value" : [[0.5, [ [ "coal", 2.20], [ "plutonium", 0.70], [ "solarium", 0.3] ] ]]
    },
    {
    "op" : "replace",
    "path" : "/moondeepores",
    "value" : [[0.5, [ [ "coal", 2.20], [ "plutonium", 0.70], [ "solarium", 0.3] ] ]]
    },
    that is in my current mod, and the only thing that is effected is the plutonium, no matter how high I crank the other two up they don't spawn.
     

Share This Page