RELEASED Content Patcher *

Loads content packs that change the game's images and data without replacing XNB files.

Thread Status:
Not open for further replies.
  1. pepoluan

    pepoluan Star Wrangler

    I understand. Editing manifest.json will be clobbered by mod updates, though. So if we can specify an order outside of the mod's files, the user-specified order will survive mod updates easily. That's another thought on why I suggested a method using CP's own config.json; I may have not made that thought clearer in my first post, apologies.
     
    • Pathoschild

      Pathoschild Cosmos Killer

      @pepoluan Setting load order that way is out of scope for Content Patcher itself, but I could certainly look into that for SMAPI if many players would find it useful. It already lets you override some things (but not load order) in its smapi-internal/StardewModdingAPI.config.json (SMAPI 2.x) or smapi-internal/config.json (SMAPI 3.0) file.
       
        pepoluan likes this.
      • Pathoschild

        Pathoschild Cosmos Killer

        Content Patcher 1.9 is now available!

        Release notes:
        • Added API to let other mods create custom tokens and conditions.
        • Fixed config parsing errors for some players.
        • Fixed tokens not being validated consistently in some cases.
        • Fixed a broken warning message.
         
          pepoluan likes this.
        • Pathoschild

          Pathoschild Cosmos Killer

          Content Patcher 1.9.1 is now available!

          Release notes:
          • Fixed error loading local XNB files in some cases with Content Patcher 1.9.
          • Fixed mod-provided tokens being asked for values when they're marked non-ready.
           
            pepoluan likes this.
          • pepoluan

            pepoluan Star Wrangler

            @Pathoschild , I noticed that an old mod "Dynamic NPC Sprites" can make NPCs wear random clothing per day.

            My thought to simulate this ability is to implement {{DailyRandom:num,variable}} token that behaves as follows:
            • It generates a random number once every start of day, so through the whole day, the same variable will return the same value
            • "variable" is optional, it's used so that characters won't use the same random number except coincidentally
            • "num" is the upper bound (inclusive) of the random number, that is, the token will return a random number between 1 & num inclusive
            With this token, it will be possible for a mod maker to create, e.g.:

            Code:
            {
                "Action": "EditImage",
                "Target": "Characters/Haley, Portraits/Haley",
                "FromFile": "assets/{{Target}}-{{DailyRandom:3,ha}}.png"
            },
            {
                "Action": "EditImage",
                "Target": "Characters/Emily, Portraits/Emily",
                "FromFile": "assets/{{Target}}-{{DailyRandom:2,em}}.png"
            }
            
            and provide the files "Characters/Haley-1.png", "Portraits/Haley-1.png", "Characters/Haley-2.png" and so on, and CP will randomly load a matching pair at the start of the day. And the mod maker only need to provide 2 pairs of PNGs for Emily (because the DailyRandom for the "em" variable is bounded to 2).
             
            • Pathoschild

              Pathoschild Cosmos Killer

              @pepoluan That could be really useful. I'd extend it to choosing random values and specifying the number range though:
              Code:
              // choose random value
              {
                  "Action": "EditImage",
                  "Target": "Characters/Abigail",
                  "FromFile": "assets/abigail-{{Random:hood, jacket, raincoat}}.png"
              }
              
              // choose random number (inclusive)
              {
                  "Action": "EditImage",
                  "Target": "Characters/Abigail",
                  "FromFile": "assets/abigail-{{Random:1-3}}.png"
              }
              
              And to coordinate randoms:
              Code:
              {
                  "Action": "EditImage",
                  "Target": "Characters/Abigail",
                  "FromFile": "assets/abigail-{{Random:hood, jacket, raincoat | abigail-outdoors}}-sprite.png"
              },
              {
                  "Action": "EditImage",
                  "Target": "Portraits/Abigail",
                  "FromFile": "assets/abigail-{{Random:hood, jacket, raincoat | abigail-outdoors}}-portrait.png" // doesn't necessarily need to be the same values
              }
              
               
                pepoluan likes this.
              • pepoluan

                pepoluan Star Wrangler

                Sounds awesome!

                Come to think of it, we don't have to use a tracking variable, actually. We can use the Dynamic Tokens instead, e.g.:

                Code:
                    "DynamicTokens": [
                        {
                            "Name": "AbigailOutdoorsRainingOutfit",
                            "Value": "{{Random:hood, jacket, raincoat}}"
                        },
                        {
                            "Name": "Style",
                            "Value": "wet",
                            "When": {
                                "Weather": "rain, storm"
                            }
                        }
                    ]
                
                then later on in the Changes:
                Code:
                {
                    "Action": "EditImage",
                    "Target": "Characters/Abigail",
                    "FromFile": "assets/abigail-{{AbigailOutdoorsRainingOutfit}}-sprite.png",
                    "When": {
                        "IsOutdoors": true,
                        "Style": "wet"
                    }
                },
                {
                    "Action": "EditImage",
                    "Target": "Portraits/Abigail",
                    "FromFile": "assets/Abigail-{{AbigailOutdoorsRainingOutfit}}-portrait.png"
                    "When": {
                        "IsOutdoors": true,
                        "Style": "wet"
                    }
                }
                Must make sure, though, that {{Random}} changes at start of day and only at start of day. If not, then everytime player leaves the area and goes back, Abigail might change appearance mid-stride, which will be quite ... strange :sweatsmile:
                 
                  Last edited: Jun 16, 2019
                • babybird22

                  babybird22 Void-Bound Voyager

                  Hi Pathoschild,
                  me again having some issues regarding the marriage mod:notworthy:
                  I have migrated this wizard marriage XNB mod to the Content Patcher pack.

                  After releasing this CP mod, a few players reported me that the game crushed after the wizard had ask for baby...
                  One player said that the game crushed immediately after he asking for baby.
                  Another player said that this happened after few days later, before the baby came.
                  However, i don't have this problem when playing the game.

                  I have checked the second players' SMAPI log, I think the issue may be caused by the spouse room, which is not included in the original XNB mod...but i don't know how to solve it.:cry::cry::cry:

                  I would be grateful if you can check the log and give me some suggestion. Thanks again!
                   
                  • Pathoschild

                    Pathoschild Cosmos Killer

                    @babybird22 That's a bug in the game code when loading spouse rooms. Normally it happens when the player gets married, and it should happen for both XNB and Content Patcher versions. I haven't seen any reports of it happening for children though, since those shouldn't affect the spouse rooms. For now the workaround is to remove the mod before the spouse room is changed (e.g. after marriage), and put it back afterwards. There's a change I requested in Stardew Valley 1.4 that should fix that.
                     
                    • babybird22

                      babybird22 Void-Bound Voyager

                      Thank you for the reply!
                      I just wonder if removing the mod will make any error when loading the game, as the wizard has already married to and lived with the farmer...
                       
                      • Pathoschild

                        Pathoschild Cosmos Killer

                        @babybird22 It might; if necessary you could also edit its content.json file to disable the Maps/Farmhouse* patches temporarily.
                         
                        • heartenvy

                          heartenvy Aquatic Astronaut

                          @Pathoschild there are a few mods i used to use (some retextures, some dialogue, i dont think it was anything big) but as ive been getting back into sdv they dont work anymore since they use versions of content patcher older than 1.7, ive looked around and through this thread but i uh. have a hard time understanding things unless theres a specific guide to follow lol .i was wondering if there was any way you could put together a tutorial or something about all the things that need changed to use the latest content patcher??
                           
                          • Pathoschild

                            Pathoschild Cosmos Killer

                            @heartenvy Older content packs should still work fine. Can you upload your SMAPI log (see instructions on that page) and post a link here, and list the ones that aren't working?
                             
                            • heartenvy

                              heartenvy Aquatic Astronaut

                            • Pathoschild

                              Pathoschild Cosmos Killer

                            • babybird22

                              babybird22 Void-Bound Voyager


                              Thank you! The issue is fixed after I have made a custom spouse room for wizard!
                               
                              • Pathoschild

                                Pathoschild Cosmos Killer

                                Content Patcher 1.9.2 is now available!

                                Release notes:
                                • Fixed Day token not allowing zero values.
                                • Fixed dynamic tokens validated before they're ready.
                                • Fixed custom tokens called with non-ready inputs in some cases.
                                • Fixed Linux/Mac players getting HasFile-related errors in some cases.
                                 
                                • Billy0815

                                  Billy0815 Void-Bound Voyager

                                  I need a little help creating a content pack. Im working on my seasonal custom buildings pack which included some of the craftables. In winter some of them are covered in snow (e.g. keg, etc,).
                                  Is it possible to create a token which allows to switch out the png when the craftables are placed indoor? In the current state the craftables are covered in snow in winter when placed in a shed or in the house.
                                   
                                  • hatmouse

                                    hatmouse Subatomic Cosmonaut

                                    There is! You can use IsOutdoors in a When condition, for example, to check whether or not the player is outside before applying a patch. You can check out all the available tokens here .

                                    So you could do something like
                                    Code:
                                    {
                                        "Action": "EditImage",
                                        "Target": "TileSheets/Craftables",
                                        "FromFile": "assets/{{season}}_craftables.png", // assets/spring_craftables.png, assets/summer_craftables.png, etc
                                        "When": {
                                          "IsOutdoors": "true"
                                        }
                                    }
                                    
                                    for applying the seasonal versions only outside, or you could combine things so that you had seasonal inside and seasonal outside, or do a regular season replace but only do the winter one depending, that kind of thing. Whatever :)
                                     
                                    • Billy0815

                                      Billy0815 Void-Bound Voyager

                                      Thanks that helped a lot!
                                       
                                      Thread Status:
                                      Not open for further replies.

                                      Share This Page