Support using Mod Call - JavidPack/Census GitHub Wiki

Spawn Condition Support

Census relies on mods to provide a user-friendly description of the conditions required for a Town NPC to spawn. The user can then see that information in the additional Town NPC portraits that appear in the Housing menu.

As of v0.5 for 1.4.4 tModLoader, the information in this wiki article is outdated. Modders don't need to use Mod.Call anymore, just fill out the localization keys that show up in the localization files.

Modders write Mod.Call code in their mod to inform Census of this infomation. Mod.Call allows for mods to communicate with each other and cooperate, more info on Mod.Call can be learned from the tModLoader wiki. This guide will go through each Mod.Call pattern and corresponding arguments in detail below.

Mod.Calls

All Mod.Call listed are expected to be used after NPC IDs are assigned, so a good place would be ModSystem.PostSetupContent. See the complete examples below to see this in action.

TownNPCCondition

Mod.Call syntax: "TownNPCCondition", int npcID, string condition
Provides the Town NPC specified by the npcID with the given spawn condition. You'll want to pass in a localized string if your mod supports localization. You can also use Chat Tags to include item images, if desired. Try to keep the condition simple and to the point.

TownNPCCondition Examples

Terraria -- Examples of the Terraria Town NPC spawn conditions provided by Cencus.
ExampleMod -- Adds ExamplePerson, shows a typical usage, English only.

int npcType = ModContent.NPCType<Content.NPCs.ExamplePerson>();
string message = $"Have either an Example Item [i:{ModContent.ItemType<Content.Items.ExampleItem>()}] or an Example Block [i:{ModContent.ItemType<Content.Items.Placeable.ExampleBlock>()}] in your inventory";
censusMod.Call("TownNPCCondition", npcType, message);