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

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

  1. The | Suit

    The | Suit Agent S. Forum Moderator

    Doing such a thing is highly likely to result in errors that would take hours to find as you will need to look at it one by one.
    It is better to write it individually to make sure that patch is viable for that file.
     
  2. sayter

    sayter The Waste of Time

    also this, because rarely is every tile in a batch identical. for mass-applying you can open the files in something like sublime text and copy/paste as needed. but again, you still need to verify the patch for each one.
     
  3. davoker

    davoker Scruffy Nerf-Herder

    Mm, it's a pity, but hey, we'll have to continue doing it one by one hehe

    I'm just having a problem with a file already converted to .patch, it's the only one of thousands of files that does not work, I've translated thousands already and everything works and nothing gives an error, but this does not want to work, I put a thread about it:

    https://community.playstarbound.com/threads/error-in-a-specific-translated-file-ctd.141697/

    The file is apparently fine, but it gives an error and I do not know how to solve it, I have even tried to redo the file in a new one, I do not know what happened xD I commented on it if by chance someone knows what could happen, I have no more ideas xD
     
  4. zekrom_vale

    zekrom_vale Tentacle Wrangler

    I don't suppose I can use JSON .patch files to add to the end of a string, instead of replacing the whole thing. Tried looking it up and rfc6902 did not have anything to do with inside strings. And no, they cannot be an array, tiled and starbound dislikes that.
    (If anyone knows how to use map spawn tiles or spawners with a species group that might work.)

    I'm using the less optimal method currently as I don't see a way to modify a string in JSON .patch, but I want to allow more compatibility with other mods that do the same thing. Here is the code for "\dungeons\space\spacestation\core_horizontal_long1a.json.patch"
    Code:
    [{
    "op": "replace",
    "path": "/layers/5/objects/0/properties/npc",
    "value": "apex, avian, floran, glitch, human, hylotl, novakid, kazdra"
    },{
    "op": "replace",
    "path": "/layers/5/objects/1/properties/npc",
    "value": "apex, avian, floran, glitch, human, hylotl, novakid, kazdra"
    },{
    "op": "replace",
    "path": "/layers/5/objects/2/properties/npc",
    "value": "apex, avian, floran, glitch, human, hylotl, novakid, kazdra"
    },{
    "op": "replace",
    "path": "/layers/5/objects/3/properties/npc",
    "value": "apex, avian, floran, glitch, human, hylotl, novakid, kazdra"
    },{
    "op": "replace",
    "path": "/layers/5/objects/4/properties/npc",
    "value": "apex, avian, floran, glitch, human, hylotl, novakid, kazdra"
    },{
    "op": "replace",
    "path": "/layers/5/objects/5/properties/npc",
    "value": "apex, avian, floran, glitch, human, hylotl, novakid, kazdra"
    }]
    Also it would be nice if we could use wildcards to apply the op to all existing paths.
    Another feature that would be nice with JSON .patch or varent would be to run the patch on all JSON files, relative to the location of the patch, that match the given file path.
     
    Last edited: Mar 27, 2018
  5. ColonolNutty

    ColonolNutty Ketchup Robot

    Couldn't you just add to the layers? Make a new layer with the above values?
     
  6. zekrom_vale

    zekrom_vale Tentacle Wrangler

    I don't think that would add to the spawner tile, instead it would likely spawn in more NPCs, if work at all.
     
  7. zekrom_vale

    zekrom_vale Tentacle Wrangler

    This is part of the JSON file I am modifying.
    Code:
    {
    "height":8,
    "id":1050,
    "name":"",
    "properties":
        {
         "npc":"apex, avian, floran, glitch, human, hylotl, novakid",
         "typeName":"spacevillager"
        },
    "propertytypes":
        {
         "npc":"string",
         "typeName":"string"
        },
    "rotation":0,
    "type":"",
    "visible":true,
    "width":8,
    "x":656,
    "y":440
    }
    
    To

    Code:
    {
    .
    .
    .
    "properties":
        {
         "npc":"apex, avian, floran, glitch, human, hylotl, novakid,kazdra",
         "typeName":"spacevillager"
        },
    .
    .
    .
    }
    
    Where "apex, avian, floran, glitch, human, hylotl, novakid" could be changed by other mods
    Note: some elements are added from tiled, but that is not relevant in this case.
    P.S. how would you deal with an escaped JSON object such as:
    Code:
     "properties":{
         "parameters":"{\"treasurePools\":[\"basicSpaceTreasure\"]}"
        },
     
    Last edited: Mar 27, 2018
  8. ColonolNutty

    ColonolNutty Ketchup Robot

    Would this work?

    Code:
    [
        {
            "op": "add",
            "path": "/layers/5/objects/-",
            "value": {
                "height":8,
                "id":1050,
                "name":"",
                "properties":
                    {
                     "npc":"apex, avian, floran, glitch, human, hylotl, novakid, kazdra",
                     "typeName":"spacevillager"
                    },
                "propertytypes":
                    {
                     "npc":"string",
                     "typeName":"string"
                    },
                "rotation":0,
                "type":"",
                "visible":true,
                "width":8,
                "x":656,
                "y":440
            }
        }
    ]
     
  9. zekrom_vale

    zekrom_vale Tentacle Wrangler

    I was hoping to avoid adding more NPCs as this will create a new spawner tile in the same location. Plus, if mod authors do this, the game will suffer with all the NPCs.
     
  10. ColonolNutty

    ColonolNutty Ketchup Robot

    Even though it has the same id?
     
  11. zekrom_vale

    zekrom_vale Tentacle Wrangler

    Yep, tiled does not use ids for some reason, even though they give an id. Even if they did, it would work the same way as a patch does, completely replacing the values, not adding to the end of a string.
     
  12. ColonolNutty

    ColonolNutty Ketchup Robot

    I was looking for alternatives for you, to my knowledge there is no way to modify a string directly, only replace it.
     
  13. zekrom_vale

    zekrom_vale Tentacle Wrangler

    One possible way might be modifying via lua or a different language, but I don't know how to run the lua file while compiling the JSON files. But my thought was to replace all paths existing paths that follow "/layers/*/objects/*/properties/npc" with the array of the species, then join it back to a string right before finishing compiling the JSON.
    Testing would only determine if it was modified, and is useless as it kills the patch.
    Still, thank you for trying!
     
  14. ColonolNutty

    ColonolNutty Ketchup Robot

    Maybe you could utilize the "move" operation? I'm not sure how helpful that'd be, but maybe you'll discover a way to use it
     
  15. zekrom_vale

    zekrom_vale Tentacle Wrangler

    Well, copy could be used instead of using the solution over and over again.
     
  16. zekrom_vale

    zekrom_vale Tentacle Wrangler

    I wonder, what would happen if you were to replace it with a list of all modded species, would starbound just ignore all the species that were not installed, or would it crash?
    Nope: Caused by: (StarException) Unknown species kind 'log'.
     
    Last edited: Mar 28, 2018
  17. zekrom_vale

    zekrom_vale Tentacle Wrangler

    A possible solution is to use a json patch file that complies right after vinila assists compile to replace "npc" to an array so other mods can add to it.
    Then hook into the lua that deals with dungeon generation and to convert all the "npc" arrays to a string before it read the JSON file.
     
  18. Carolusclen

    Carolusclen Big Damn Hero

    hey, ok, im trying to play around with this as I plan on starting to mod Starbound. This is my first attempt and its not going to well

    So I am testing this patching system and all I want to do is add something to the ship locker.
    Note the mod I have in mind down the line will be reliant on Frackin Universe and Avali Triage.
    I have the metadata folder accurate as the game when i launch it detects the mod which im guessing is good

    then in the my mod folder i create a folder called "treasure" and in there is a file called "shiplocker.treasurepools.patch"
    in this file i have the following

    Code:
    [
      {"op":"add","path":"/defaultBlueprints/tier1/-","value":{"item":[ "copperbar", 100 ]} }
    ]
    so the only 3 mods I have are my mod im testing with, Avali, the character extender for avali and FU.
    when i create a new character, the copper is not there.

    just as an FYI, here is my metadata file too as its the only other file I have, and yes, i know this topic is not for metadata files but just want to rule it out.

    _metadata
    Code:
    {
      "name" : "test",
      "friendlyName" : "test",
      "description" : "test",
      "author" : "test",
      "version" : "0.1 - Alpha",
      "priority" : 0,
      "includes" : ["FrackinUniverse", "Avali"]
    }
     
    Last edited: Mar 30, 2018
  19. Yanazake

    Yanazake Space Kumquat

    Haa, my brain hurts... I'm not trying to add things to base/new characters, but instead to already modded items. Yeah, modding mods.

    Does that mean I'd have to make a .patch file in the same folder structure as the original mod to edit, say, a certain item so it teachs blueprints on pickup?
     
  20. NexusTheBrony

    NexusTheBrony Parsec Taste Tester

    I always treat the base game assets as a huge mod, bc mods work exactly the same as the base game assets. so any patching instructions here work similarly for mods
     
    Yanazake likes this.

Share This Page