Modding Help How can i patch Weather.config ?

Discussion in 'Starbound Modding' started by WyvernX1, Mar 7, 2024.

Tags:
  1. WyvernX1

    WyvernX1 Scruffy Nerf-Herder

    Hey
    got small question on how do i make proper patch for Weather.config file in root folder

    I want to change this planets weather from these numbers to 1 so all can happen on this planet
    "garden" : [
    [0.05, "rain"],
    [0.025, "storm"],
    [0.0125, "glowingrain"],
    [0.0625, "drizzle"],
    [0.85, "clear"]
    ],

    do i need to make patch for this or can i just edit the whole file a make mod from it?

    ( i did played around with the patch maker and i got this result, i have no idea if thats correct )

    [
    {
    "op": "replace",
    "path": "/garden/0/0",
    "value": 1.0
    },
    {
    "op": "replace",
    "path": "/garden/1/0",
    "value": 1.0
    },
    {
    "op": "replace",
    "path": "/garden/2/0",
    "value": 1.0
    },
    {
    "op": "replace",
    "path": "/garden/3/0",
    "value": 1.0
    },
    {
    "op": "replace",
    "path": "/garden/4/0",
    "value": 1.0
    }
    ]

    If im correct, then the first number after the "garden" is the 1st value ( "rain" ) but what is the second value "0" ?
    or should there be only 1 value after the "garden" ?
     
    Last edited: Mar 7, 2024
  2. DrVoodoo

    DrVoodoo Cosmic Narwhal

    Uh... Not a modder, and I'm not sure if that's the answer you were looking for - but to me they seem like chance multipliers, where 0 is 0% and 1 is 100%. They all add up to 1. In this case, setting the chances of all weathers to 100% will most likely result in conflicts, as I don't see how it would be possible to have ALL weathers at the same time.
     
  3. WyvernX1

    WyvernX1 Scruffy Nerf-Herder

    I do understand that this is NOT percentage, but "Weight", but at the same time, some planets can have all weathers 100% sure.
    As well as some other games that have this "weight" system works even if you have all set to 1
     
  4. rl.starbound

    rl.starbound Phantasmal Quasar

    The values are just weights, not percentages. You sum the weight for all options. Then you divide a specific option's weight by the sum to get that option's percentage likelihood. You can use any numeric value for the weights; doesn't have to sum to 1.

    As for the patch notation...

    The weather.config file, and most other Starbound asset files, is written in JSON. JSON counts lists using 0 as the first value. So the path "/garden/0/0" refers to the key "garden" inside the JSON file. That key's value will be a list. We select the first item in the list, in this case [0.05, "rain"]. This item is, itself, a list. We select the first item of that list, in this case, 0.05. And we replace that value with 1.0. And likewise, this patch steps through every subsequent entry and changes its first value to 1.0.

    JSON patch syntax is a simple declarative syntax. Unfortunately, there is no cleaner way to express "replace the first element of every item with 1.0" using JSON patch syntax.

    As an alternative, you could replace the entire garden value with your own:

    Code:
    {
      "op": "replace",
      "path": "/garden",
      "value": [
        [1, "rain"],
        [1, "storm"],
        [1, "glowingrain"],
        [1, "drizzle"],
        [1, "clear"]
      ]
    }
    However, this will conflict with other mods that also modify the garden weather. To minimize conflicts, it's always best to make the most highly focused JSON patches possible to accomplish your goals.
     
    WyvernX1 likes this.
  5. WyvernX1

    WyvernX1 Scruffy Nerf-Herder

    Thanks buddy, thats exactly what i found after some searching :D
    Also i was looking into Frackin Universe, its similar, but with many changes.
     

Share This Page