Modding Help Cooking Collection Patch

Discussion in 'Starbound Modding' started by HellHype, Feb 27, 2017.

  1. HellHype

    HellHype Space Hobo

    So im creating this mod, where I add some food and recipes. Since there is this cooking.collection thing, I wanted to implement my items into there.
    I tried using a cooking.collection.patch with this code:

    Code:
    [
    {
    "op": "add",
    "path": "/collectables/-",
    "value": "spaghetti" : {
               "order" : 151,
               "item" : "pasta"
             }
    },{
    "op": "add",
    "path": "/collectables/-",
    "value": "spaghetti" : {
               "order" : 152,
               "item" : "spaghetti"
             }
    }
    ]
    but it doesn't work with other mods (because they also add a collectable at the order 151/152)
    I wanted to know, if instead of typing a number for "order", I could use some trick, to put it at the end of the list. (like the ".../-" for paths)
     
  2. IHart

    IHart Scruffy Nerf-Herder

    you could do a workaround where you run the test command to see which other mods are present and add yours adaptively
     
  3. IHart

    IHart Scruffy Nerf-Herder

    a cleaner solution would probably be to add your own collection category
     
  4. HellHype

    HellHype Space Hobo

    sry im new to modding, so could you make an example please? I dont know any test command :oops:
     
  5. IHart

    IHart Scruffy Nerf-Herder

  6. HellHype

    HellHype Space Hobo

    thanks, I will read into it!

    for example frackin universe is causing issues, by adding some food to the collection
    the cooking.collection.patch:
    Code:
    [
        {     "op": "add",
            "path": "/collectables/meatchunk",
            "value":        
            {
              "order" : 151,
              "item" : "meatchunk"
            }
        },
      
        {     "op": "add",
            "path": "/collectables/avikanmeal",
            "value":        
            {
              "order" : 152,
              "item" : "avikanmeal"
            }
        },
      
        {     "op": "add",
            "path": "/collectables/bolbohnjam",
            "value":        
            {
              "order" : 153,
              "item" : "bolbohnjam"
            }
        },
      
        {     "op": "add",
            "path": "/collectables/spicebol",
            "value":        
            {
              "order" : 154,
              "item" : "spicebol"
            }
        },
      
        {     "op": "add",
            "path": "/collectables/dunebun",
            "value":        
            {
              "order" : 155,
              "item" : "dunebun"
            }
        },
      
        {     "op": "add",
            "path": "/collectables/stuffeddunebun",
            "value":        
            {
              "order" : 156,
              "item" : "stuffeddunebun"
            }
        },
      
        {     "op": "add",
            "path": "/collectables/kadavancactusjuice",
            "value":        
            {
              "order" : 157,
              "item" : "kadavancactusjuice"
            }
        },
      
        {     "op": "add",
            "path": "/collectables/kadavanmeatjuice",
            "value":        
            {
              "order" : 158,
              "item" : "kadavanmeatjuice"
            }
        }
    ]
    of course I could just make my code to fit that perfectly, so that it starts with 159, then 160 ... but if I were to publish my mod, it would still be incompatible, if the user has different mods though
     
  7. IHart

    IHart Scruffy Nerf-Herder

    The better solution is to just create your own collection category. There is no way to make a "smart" patch as you are describing, you would need to test for each mod individually.

    The patch for FU would look like this:
    Code:
    [[
      {
      "op" : "test",
      "path" : "/collectables/kadavanmeatjuice"
      },
      {
      "op": "add",
      "path": "/collectables/spaghetti",
      "value": {
      "order" : 159,
      "item" : "pasta"
      }
      },
      {
      "op": "add",
      "path": "/collectables/spaghetti0",
      "value": {
      "order" : 160,
      "item" : "spaghetti"
      }
      }
    ],[
      {
      "op" : "test",
      "path" : "/collectables/kadavanmeatjuice",
      "inverse" : "true"
      },
      {
      "op": "add",
      "path": "/collectables/spaghetti",
      "value": {
      "order" : 151,
      "item" : "pasta"
      }
      },
      {
      "op": "add",
      "path": "/collectables/spaghetti0",
      "value": {
      "order" : 152,
      "item" : "spaghetti"
      }
      }
    ]]
    But this way gets increasingly complicated the more mods you have to account for.

    side note: ending the path with a hyphen works for adding to the end of an array [], not to an object {}.
     
    HellHype likes this.
  8. HellHype

    HellHype Space Hobo

    Too bad. I thought there was something implemented like this. I will just make my own collection then. Thanks anyway!
     

Share This Page