Skip to content

Commit

Permalink
v0.5.2, register the text passed into obsolete Mod.Call as value of a…
Browse files Browse the repository at this point in the history
…utokey.
  • Loading branch information
JavidPack committed May 31, 2023
1 parent 066fee1 commit 5052dda
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
7 changes: 4 additions & 3 deletions CensusSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
16 changes: 8 additions & 8 deletions Localization/en-US_Mods.Census.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
}
10 changes: 10 additions & 0 deletions TownNPCInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 5052dda

Please sign in to comment.