Label by Ingredients - Vanilla-Expanded/VanillaExpandedFramework GitHub Wiki

<- Back

CompProperties_LabelByIngredients makes a thing change its label depending on its list of ingredients. The thing needs to have CompProperties_Ingredients or, probably, EVERYTHING WILL EXPLODE

        //If true, whole label will be replaced. Otherwise, it will be appended: "override + originalLabel"
        public bool fullReplace = false;
        public Dictionary<ThingDef, string> overrides = new Dictionary<ThingDef, string>();
        public List<ThingDef> exclusions = new List<ThingDef>();

How do I use this code?

It is a comp class, so you just add it in XML in the <comps> tag of the ThingDef. For example, this is butter in Alpha Crafts:

<comps>
	<li Class="VEF.Things.CompProperties_LabelByIngredients">
		<fullReplace>true</fullReplace>
		<overrides>
			<li>
				<key>SmokeleafLeaves</key>
				<value>Hemp butter</value>
			</li>
			<li>
				<key>RawCorn</key>
				<value>Margarine</value>
			</li>
			<li>
				<key>Chocolate</key>
				<value>Cocoa spread</value>
			</li>
			<li>
				<key>Milk</key>
				<value>Butter</value>
			</li>
		</overrides>
	</li>
</comps>

This is tea sachets. Overrides is empty so it can be patched via XPATH:

<comps>
	<li Class="VEF.Things.CompProperties_LabelByIngredients">
		<exclusions>
			<li>VBE_RawTea</li>
		</exclusions>
		<overrides>
			
		</overrides>
	</li>
</comps>
⚠️ **GitHub.com Fallback** ⚠️