Coding Help Mod help! Farmer Portraits

tenshiya

Cowpoke
Hello! I downloaded the Farmer Portraits mod, which shows a portrait of your farmer on the left side of dialogue boxes. I have some drawings of my farmer that I'm trying to use, and was able to get one portrait to work with this as my content.json contents:

Code:
{
    "Format": "1.4",
    "Changes": [
        {
            "Action": "Load",
            "Target": "aedenthorn.FarmerPortraits/portrait",
            "FromFile": "assets/spring_portrait.png",
            "When": {
            "Season": "spring",
            "Weather": "sun, wind, rain"}
        }
    ]
}
I believe I have everything setup correctly since I was able to get one custom portrait to work. However, I am now trying to use dynamic tokens to set different portraits for different seasons/festivals but can't seem to get any custom portraits to show up now with the updated content.json. It's only showing the non-custom portrait/pixel character sprite even though I have "UseCustomPortrait" set to True. I'm also not getting any errors about this in SMAPI. Here's the content.json fileI've edited -- does anyone know why this isn't working? I thought the {{style}} placeholder in the line - "FromFile": "assets/piper_{{style}}.png" - would populate based on my values I set in the DynamicTokens section, but maybe I'm not understanding how to do this correctly? Any help/input would be greatly appreciated!!!

Code:
{
    "Format": "1.4",
    "DynamicTokens": [
        {
            "Name": "Style",
            "Value": "spring",
            "When": {
            "Season": "spring",
            "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "summer",
            "When": {
            "Season": "summer",
            "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "fall",
            "When": {
            "Season": "fall",
            "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "winter",
            "When": {
            "Season": "winter",
            "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "aerobics",
            "When": {
                "DayOfWeek": "Tuesday",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "flowerdance",
            "When": {
                "DayEvent": "flower dance",
                "Season": "spring",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "spiritseve",
            "When": {
                "DayEvent": "spirit's eve",
                "Season": "fall",
                "Weather": "sun, wind, rain, storm, snow"
            }       
        },
        {
            "Name": "Style",
            "Value": "wedding",
            "When": {
                "DayEvent": "wedding"
            }
        }
    ],
    "Changes": [
        {
            "Action": "Load",
            "Target": "aedenthorn.FarmerPortraits/portrait",
            "FromFile": "assets/piper_{{style}}.png"
        }
    ]
}
 

tenshiya

Cowpoke
Nvm!! There was an error logged that I missed. DynamicTokens can only be used with a format version of 1.5.0 or up!
 

tenshiya

Cowpoke
hey did you get it to work? could you share how you did if so?
Yes! My issue was that the format version of my content.json file was not set to a version that DynamicTokens was compatible with, so I just had to change the format version from 1.4 -> 1.5.

Here's my content.json if you want to use it as a reference:
You need to add your portraits to the assets folder of the Farmer Portrait mod with specific names. For example, I have portraits named piper_aerobics.png, piper_fall.png, piper_flowerdance.png, etc. which will load based on the season/holiday.

JSON:
{
    "Format": "1.5",
    "DynamicTokens": [
        {
            "Name": "Style",
            "Value": "spring",
            "When": {
            "Season": "spring",
            "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "summer",
            "When": {
            "Season": "summer",
            "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "fall",
            "When": {
            "Season": "fall",
            "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "winter",
            "When": {
            "Season": "winter",
            "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "aerobics",
            "When": {
                "DayOfWeek": "Tuesday",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "flowerdance",
            "When": {
                "DayEvent": "flower dance"
            }
        },
        {
            "Name": "Style",
            "Value": "spiritseve",
            "When": {
                "DayEvent": "spirit's eve"
            }       
        },
        {
            "Name": "Style",
            "Value": "wedding",
            "When": {
                "DayEvent": "wedding"
            }
        }
    ],
    "Changes": [
        {
            "Action": "Load",
            "Target": "aedenthorn.FarmerPortraits/portrait",
            "FromFile": "assets/piper_{{style}}.png"
        }
    ]
}
I've been playing with the portraits for two in-game years now and everything is working fine!
 

NatRaingerECT

Newcomer
Kudos dude!

Could I ask for your assistance please? I tried tinkering and making the script similar for my own farmer.. and for some reason it won't change the portraits even though everything I did is technically correct according to both the JSON validator and SMAPI.



JSON:
{
    "Format": "1.28.0",
    "DynamicTokens": [
        {
            "Name": "Style",
            "Value": "spring",
            "When": {
                "Season": "spring",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "summer",
            "When": {
                "Season": "summer",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "fall",
            "When": {
                "Season": "fall",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "winter",
            "When": {
                "Season": "winter",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "aerobics",
            "When": {
                "DayOfWeek": "Tuesday",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "flowerdance",
            "When": {
                "DayEvent": "flower dance"
            }
        },
        {
            "Name": "Style",
            "Value": "icefestival",
            "When": {
                "DayEvent": "ice festival"
            }
        },
        {
            "Name": "Style",
            "Value": "svfair",
            "When": {
                "DayEvent": "stardew valley fair"
            }
        },
        {
            "Name": "Style",
            "Value": "spiritseve",
            "When": {
                "DayEvent": "spirit's eve"
            }       
        },
        {
            "Name": "Style",
            "Value": "winterstar",
            "When": {
                "DayEvent": "winter star"
            }
        },
        {
            "Name": "Style",
            "Value": "wedding",
            "When": {
                "DayEvent": "wedding"
            }
        }
    ],
    "Changes": [
        {
            "Action": "Load",
            "Target": "aedenthorn.FarmerPortraits/portrait",
            "FromFile": "assets/nathan_{{style}}.png"
        }
    ]
}
 
Last edited:

NatRaingerECT

Newcomer
Okay so! I was a dummy and didn't notice I forgot the events I was testing!
Here's an updated code that seems to be working for me.

Please note Before use!!!
*** It currently only holds portraits because I am not a java script developer and am already VERY LAZY so bare with me.
*** It's fit to the current version of Content Patcher. Please Make sure to change the version in the script accordingly in the new updates.
*** When Naming your portraits, make sure to follow the YOURFARMERNAME_{{style}}.png format for each event. It's curial for the code to identify which PNG to pick.
*** I haven't tested the Swimsuit and wedding yet, so if you find a bug I'd love to know! I'll fix it accordingly~

The script Includes portraits for:

4 Seasons:

- Spring
- Summer
- Fall
- Winter

Festivals:

- Egg Festival
- Flower Dance
- Luau
- Moonlight Jellies
- SVFair
- Spirit's Eve
- Ice Festival
- Winter Star

Misc:

Swimsuit
Aerobics
Wedding

The Json:

JSON:
{
    "Format": "1.29.0",
    "DynamicTokens": [
        {
            "Name": "Style",
            "Value": "spring",
            "When": {
                "Season": "spring",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "summer",
            "When": {
                "Season": "summer",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "fall",
            "When": {
                "Season": "fall",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "winter",
            "When": {
                "Season": "winter",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },

        {
            "Name": "Style",
            "Value": "aerobics",
            "When":
            {
                "DayOfWeek": "Tuesday",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "flowerdance",
            "When": {
                "DayEvent": "flower dance"
            }
        },
        {
            "Name": "Style",
            "Value": "swimsuit",
            "When":
            {
                "LocationName": "beach",
                "Season": "summer",
                "DayEvent |contains=Luau, Dance of the Moonlight Jellies": "false",
                "SwimSuitsEnabled": "true"
            }
        },
        {
            "Name": "Style",
            "Value": "spiritseve",
            "When": {
                "DayEvent": "spirit's eve"
            }       
        },
        {
            "Name": "Style",
            "Value": "svfair",
            "When": {
                "DayEvent": "SVfair"
            }       
        },
        {
            "Name": "Style",
            "Value": "eggfestival",
            "When": {
                "DayEvent": "Egg Festival"
            }       
        },
        {
            "Name": "Style",
            "Value": "luau",
            "When": {
                "DayEvent": "Luau"
            }       
        },
        {
            "Name": "Style",
            "Value": "moonlightjellies",
            "When": {
                "DayEvent": "Dance of the Moonlight Jellies"
            }       
        },
        {
            "Name": "Style",
            "Value": "icefestival",
            "When": {
                "DayEvent": "Ice Festival"
            }       
        },
        {
            "Name": "Style",
            "Value": "winterstar",
            "When": {
                "DayEvent": "winterstar"
            }       
        },
        {
            "Name": "Style",
            "Value": "wedding",
            "When": {
                "DayEvent": "wedding"
            }
        }
    ],
    "Changes": [
        {
            "Action": "Load",
            "Target": "aedenthorn.FarmerPortraits/portrait",
            "FromFile": "assets/nathan_{{style}}.png"
        }
    ]
}
 

cha38

Newcomer
Hey there!

I tried to take your code for the swimsuit config option and drop it into the file, but SMAPI gave me an error message and said that it didn't work, it said:

"[Content Patcher] Ignored (CP) Seasonal Farmer Portrait > Load aedenthorn.FarmerPortraits/portrait #5: the When field is invalid: using token LocationName requires Format version 1.8.0 or later."

I added the exact code below, just like what you had posted in one of your messages (at least I think that this is correct, with no typos). (also, I made sure to use tab instead of a bunch of spaces when typing into the config file.

{
"Action": "Load",
"Target": "aedenthorn.FarmerPortraits/portrait",
"FromFile": "assets/portrait_swimsuit.png",
"When":
{
"LocationName": "beach",
"Season": "summer",
"DayEvent |contains=Luau, Dance of the Moonlight Jellies": "false",
"SwimSuitsEnabled": "true"
}
}

What can I do to fix this so that SMAPI won't ignore the code? Thanks :)
 

Lumine

Greenhorn
Hey! Any idea on how I can fix the swimsuit not being recognized? (Sorry its a big chunk of text, it seems to be reading my other mods as well.)

"[Content Patcher] Ignored (CP) Seasonal Farmer Portrait > 'Style' token: its When field is invalid: 'SwimSuitsEnabled' isn't a valid condition; must be one of AbsoluteFilePath, atravita.GingerIslandMainlandAdjustments/Bartender, atravita.GingerIslandMainlandAdjustments/Islanders, atravita.GingerIslandMainlandAdjustments/IslandOpen, atravita.GingerIslandMainlandAdjustments/Musician, Candidus42.LittleNPCs/FirstLittleNPCDisplayName, Candidus42.LittleNPCs/FirstLittleNPCGender, Candidus42.LittleNPCs/FirstLittleNPCName, Candidus42.LittleNPCs/SecondLittleNPCDisplayName, Candidus42.LittleNPCs/SecondLittleNPCGender, Candidus42.LittleNPCs/SecondLittleNPCName, ChildGenders, ChildNames, Count, DailyLuck, Day, DayEvent, DayOfWeek, DaysPlayed, FarmCave, FarmhouseUpgrade, FarmName, FarmType, FirstValidFile, FormatAssetName, HasActiveQuest, HasCaughtFish, HasConversationTopic, HasCookingRecipe, HasCraftingRecipe, HasDialogueAnswer, HasFile, HasFlag, HasMod, HasProfession, HasReadLetter, HasSeenEvent, HasValue, HasWalletItem, HavingChild, Hearts, I18n, InternalAssetKey, IsCommunityCenterComplete, IsJojaMartComplete, IsMainPlayer, IsOutdoors, Language, LFM/EnableDuringStorms, LocationContext, LocationName, LocationOwnerId, LocationUniqueName, Loe2run.ChildToNPC/FirstChildBed, Loe2run.ChildToNPC/FirstChildBirthday, Loe2run.ChildToNPC/FirstChildGender, Loe2run.ChildToNPC/FirstChildName, Loe2run.ChildToNPC/FirstChildParent, Loe2run.ChildToNPC/FourthChildBed, Loe2run.ChildToNPC/FourthChildBirthday, Loe2run.ChildToNPC/FourthChildGender, Loe2run.ChildToNPC/FourthChildName, Loe2run.ChildToNPC/FourthChildParent, Loe2run.ChildToNPC/NumberTotalChildren, Loe2run.ChildToNPC/SecondChildBed, Loe2run.ChildToNPC/SecondChildBirthday, Loe2run.ChildToNPC/SecondChildGender, Loe2run.ChildToNPC/SecondChildName, Loe2run.ChildToNPC/SecondChildParent, Loe2run.ChildToNPC/ThirdChildBed, Loe2run.ChildToNPC/ThirdChildBirthday, Loe2run.ChildToNPC/ThirdChildGender, Loe2run.ChildToNPC/ThirdChildName, Loe2run.ChildToNPC/ThirdChildParent, Loe2run.FamilyPlanning/FirstChildIsToddler, Loe2run.FamilyPlanning/FirstChildName, Loe2run.FamilyPlanning/FourthChildIsToddler, Loe2run.FamilyPlanning/FourthChildName, Loe2run.FamilyPlanning/SecondChildIsToddler, Loe2run.FamilyPlanning/SecondChildName, Loe2run.FamilyPlanning/ThirdChildIsToddler, Loe2run.FamilyPlanning/ThirdChildName, Lowercase, Merge, mistyspring.spousesisland/AllowChildren, mistyspring.spousesisland/CanVisitIsland, mistyspring.spousesisland/Devan, mistyspring.spousesisland/HasChildren, mistyspring.spousesisland/Invited, mistyspring.spousesisland/IslandAtt, PathPart, PeacefulEnd.AlternativeTextures/Textures, PeacefulEnd.AlternativeTextures/Tools, PeacefulEnd.CustomCompanions/Companions, PeacefulEnd.FashionSense/Appearance, PeacefulEnd.SolidFoundations/BuildingTexture, PeacefulEnd.SolidFoundations/IsBuildingHere, PlayerGender, PlayerName, PreferredPet, Pregnant, Query, Random, Range, Relationship, Render, Roommate, Round, Season, SkillLevel, spacechase0.JsonAssets/BigCraftableId, spacechase0.JsonAssets/BigCraftableSpriteTilesheet, spacechase0.JsonAssets/BigCraftableSpriteX, spacechase0.JsonAssets/BigCraftableSpriteY, spacechase0.JsonAssets/ClothingId, spacechase0.JsonAssets/CropId, spacechase0.JsonAssets/CropSpriteTilesheet, spacechase0.JsonAssets/CropSpriteX, spacechase0.JsonAssets/CropSpriteY, spacechase0.JsonAssets/FruitTreeId, spacechase0.JsonAssets/FruitTreeSpriteTilesheet, spacechase0.JsonAssets/FruitTreeSpriteX, spacechase0.JsonAssets/FruitTreeSpriteY, spacechase0.JsonAssets/HatId, spacechase0.JsonAssets/HatSpriteTilesheet, spacechase0.JsonAssets/HatSpriteX, spacechase0.JsonAssets/HatSpriteY, spacechase0.JsonAssets/ObjectId, spacechase0.JsonAssets/ObjectSpriteTilesheet, spacechase0.JsonAssets/ObjectSpriteX, spacechase0.JsonAssets/ObjectSpriteY, spacechase0.JsonAssets/WeaponId, spacechase0.JsonAssets/WeaponSpriteTilesheet, spacechase0.JsonAssets/WeaponSpriteX, spacechase0.JsonAssets/WeaponSpriteY, Spouse, Style, Time, Uppercase, Weather, Year."
Okay so! I was a dummy and didn't notice I forgot the events I was testing!
Here's an updated code that seems to be working for me.

Please note Before use!!!
*** It currently only holds portraits because I am not a java script developer and am already VERY LAZY so bare with me.
*** It's fit to the current version of Content Patcher. Please Make sure to change the version in the script accordingly in the new updates.
*** When Naming your portraits, make sure to follow the YOURFARMERNAME_{{style}}.png format for each event. It's curial for the code to identify which PNG to pick.
*** I haven't tested the Swimsuit and wedding yet, so if you find a bug I'd love to know! I'll fix it accordingly~

The script Includes portraits for:

4 Seasons:

- Spring
- Summer
- Fall
- Winter

Festivals:

- Egg Festival
- Flower Dance
- Luau
- Moonlight Jellies
- SVFair
- Spirit's Eve
- Ice Festival
- Winter Star

Misc:

Swimsuit
Aerobics
Wedding

The Json:

JSON:
{
    "Format": "1.29.0",
    "DynamicTokens": [
        {
            "Name": "Style",
            "Value": "spring",
            "When": {
                "Season": "spring",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "summer",
            "When": {
                "Season": "summer",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "fall",
            "When": {
                "Season": "fall",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "winter",
            "When": {
                "Season": "winter",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },

        {
            "Name": "Style",
            "Value": "aerobics",
            "When":
            {
                "DayOfWeek": "Tuesday",
                "Weather": "sun, wind, rain, storm, snow"
            }
        },
        {
            "Name": "Style",
            "Value": "flowerdance",
            "When": {
                "DayEvent": "flower dance"
            }
        },
        {
            "Name": "Style",
            "Value": "swimsuit",
            "When":
            {
                "LocationName": "beach",
                "Season": "summer",
                "DayEvent |contains=Luau, Dance of the Moonlight Jellies": "false",
                "SwimSuitsEnabled": "true"
            }
        },
        {
            "Name": "Style",
            "Value": "spiritseve",
            "When": {
                "DayEvent": "spirit's eve"
            }      
        },
        {
            "Name": "Style",
            "Value": "svfair",
            "When": {
                "DayEvent": "SVfair"
            }      
        },
        {
            "Name": "Style",
            "Value": "eggfestival",
            "When": {
                "DayEvent": "Egg Festival"
            }      
        },
        {
            "Name": "Style",
            "Value": "luau",
            "When": {
                "DayEvent": "Luau"
            }      
        },
        {
            "Name": "Style",
            "Value": "moonlightjellies",
            "When": {
                "DayEvent": "Dance of the Moonlight Jellies"
            }      
        },
        {
            "Name": "Style",
            "Value": "icefestival",
            "When": {
                "DayEvent": "Ice Festival"
            }      
        },
        {
            "Name": "Style",
            "Value": "winterstar",
            "When": {
                "DayEvent": "winterstar"
            }      
        },
        {
            "Name": "Style",
            "Value": "wedding",
            "When": {
                "DayEvent": "wedding"
            }
        }
    ],
    "Changes": [
        {
            "Action": "Load",
            "Target": "aedenthorn.FarmerPortraits/portrait",
            "FromFile": "assets/nathan_{{style}}.png"
        }
    ]
}
 
Top