diff --git a/CensusSystem.cs b/CensusSystem.cs index ef285bd..2bdeaae 100644 --- a/CensusSystem.cs +++ b/CensusSystem.cs @@ -514,12 +514,13 @@ public object Call(params object[] args) { // Where should other mods call? They could call at end of Load? string message = args[0] as string; if (message == "TownNPCCondition") { - if (args.Length >= 3 && args[2] is not LocalizedText) { + int type = Convert.ToInt32(args[1]); + if (args.Length >= 3 && args[2] is string conditionString) { + modTownNPCsInfos.Add(new TownNPCInfo(type, conditionString)); throw new Exception($"Call Error: The 2nd parameter of TownNPCCondition is now LocalizedText and is optional. Also, localization is now automatic, keys will appear in your hjson files. This TownNPCCondition Mod.Call is only needed if using LocalizedText.WithFormatArgs"); } - int type = Convert.ToInt32(args[1]); - LocalizedText condition = args[2] as LocalizedText; // when are lang files ready? + LocalizedText condition = args[2] as LocalizedText; modTownNPCsInfos.Add(new TownNPCInfo(type, condition)); return "Success"; } diff --git a/Localization/en-US_Mods.Census.hjson b/Localization/en-US_Mods.Census.hjson index 1e1d713..a3ce483 100644 --- a/Localization/en-US_Mods.Census.hjson +++ b/Localization/en-US_Mods.Census.hjson @@ -43,7 +43,7 @@ Next: Next SpawnConditions: { Unknown: Conditions unknown Guide: Always available, spawned on world generation - Merchant: Have [i/s50:72] in your inventory + Merchant: Have [i/s50:SilverCoin] in your inventory Nurse: Have more than 100 HP and for the Merchant to have arrived Demolitionist: Have an explosive in your inventory DyeTrader: Find dye item and either defeat boss or find strange plant @@ -61,22 +61,22 @@ SpawnConditions: { Mechanic: Find in the dungeon PartyGirl: Acquire 14 other townspeople Wizard: Find in the cavern layer in hardmode - TaxCollector: In hardmode, purify tortured soul with {$ItemName.PurificationPowder} [i:66] in the underworld + TaxCollector: In hardmode, purify tortured soul with {$ItemName.PurificationPowder} [i:PurificationPowder] in the underworld Truffle: In hardmode, build a house in an above ground mushroom biome Pirate: When a Pirate invasion has been defeated Steampunker: When a Mechanical boss has been defeated Cyborg: When Plantera has been defeated SantaClaus: When Frost Legion has been defeated, only during December 15-31 Princess: Have all other town npcs in the world - TownCat: Use {$ItemName.LicenseCat} [i:4829], sold by Zoologist - TownDog: Use {$ItemName.LicenseDog} [i:4830], sold by Zoologist - TownBunny: Use {$ItemName.LicenseBunny} [i:4910], sold by Zoologist + TownCat: Use {$ItemName.LicenseCat} [i:LicenseCat], sold by Zoologist + TownDog: Use {$ItemName.LicenseDog} [i:LicenseDog], sold by Zoologist + TownBunny: Use {$ItemName.LicenseBunny} [i:LicenseBunny], sold by Zoologist TownSlimeBlue: When King Slime has been defeated. TownSlimeGreen: When there is a naturally occurring Party. TownSlimeOld: Unlock an Old Shaking Chest in the Cavern Layer with a {$ItemName.GoldenKey} [i:GoldenKey] after defeating Skeletron. TownSlimePurple: Break the balloon of the Clumsy Balloon Slime in the Space Layer. - TownSlimeRainbow: Drop {$ItemName.GelBalloon} [i:4986] into Shimmer. + TownSlimeRainbow: Drop {$ItemName.GelBalloon} [i:GelBalloon] into Shimmer. TownSlimeRed: Fished up during a Blood Moon. - TownSlimeYellow: Use {$ItemName.PurificationPowder} [i:66] on a Mystic Frog in the Jungle. - TownSlimeCopper: Drop a {$ItemName.CopperHelmet} [i:89] or a {$ItemName.CopperShortsword} [i:3507] on a slime. + TownSlimeYellow: Use {$ItemName.PurificationPowder} [i:PurificationPowder] on a Mystic Frog in the Jungle. + TownSlimeCopper: Drop a {$ItemName.CopperHelmet} [i:CopperHelmet] or a {$ItemName.CopperShortsword} [i:CopperShortsword] on a slime. } \ No newline at end of file diff --git a/TownNPCInfo.cs b/TownNPCInfo.cs index 73f624e..6d567a3 100644 --- a/TownNPCInfo.cs +++ b/TownNPCInfo.cs @@ -27,6 +27,16 @@ public TownNPCInfo(int type, LocalizedText conditions = null) { } } + internal TownNPCInfo(int type, string conditions) { + this.type = type; + if (!CensusConfigClient.Instance.DisableAutoLocalization) { + this.conditions = ModContent.GetModNPC(type).GetLocalization("Census.SpawnCondition", () => conditions); + } + else { + this.conditions = Language.GetText("Mods.Census.SpawnConditions.Unknown"); + } + } + public TownNPCInfo(ModNPC modNPC) { // No localization provided, use automatic. this.type = modNPC.Type; diff --git a/build.txt b/build.txt index 9c23ed9..1535e75 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = jopojelly -version = 0.5.1 +version = 0.5.2 displayName = Census - Town NPC Checklist homepage = https://forums.terraria.org/index.php?threads/census-town-npc-checklist.74786/ hideCode = false