Editing Modding Tutorials/MayRequire
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:MayRequire}} | {{DISPLAYTITLE:MayRequire}} | ||
− | {{ | + | {{:Modding_Tutorials/Under_Review}} |
<code>MayRequire</code> is an [[Modding_Tutorials/Introduction_to_XML|XML attribute]] introduced alongside the [[Royalty DLC]] that allows for easy conditional loading of XML content. <code>MayRequire</code> makes it easier to load content that is optionally dependent on DLCs or other mods. | <code>MayRequire</code> is an [[Modding_Tutorials/Introduction_to_XML|XML attribute]] introduced alongside the [[Royalty DLC]] that allows for easy conditional loading of XML content. <code>MayRequire</code> makes it easier to load content that is optionally dependent on DLCs or other mods. | ||
Line 13: | Line 13: | ||
* Ideology: <code>Ludeon.RimWorld.Ideology</code> | * Ideology: <code>Ludeon.RimWorld.Ideology</code> | ||
* Biotech: <code>Ludeon.RimWorld.Biotech</code> | * Biotech: <code>Ludeon.RimWorld.Biotech</code> | ||
− | |||
The <code>packageId</code> for mods can be found in their [[About.xml]] file. | The <code>packageId</code> for mods can be found in their [[About.xml]] file. | ||
Line 20: | Line 19: | ||
By default, <code>MayRequire</code> will only allow the use of that node if ''all'' of the DLCs or mods it designates are loaded. If you instead want to load the specified node if ''any'' of the specified DLCs or mods are loaded, you can use <code>MayRequireAnyOf</code> instead. | By default, <code>MayRequire</code> will only allow the use of that node if ''all'' of the DLCs or mods it designates are loaded. If you instead want to load the specified node if ''any'' of the specified DLCs or mods are loaded, you can use <code>MayRequireAnyOf</code> instead. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== List Entries == | == List Entries == | ||
Line 36: | Line 27: | ||
{| class="TutorialCodeTable" | {| class="TutorialCodeTable" | ||
! XML Example !! Description | ! XML Example !! Description | ||
+ | |- | ||
+ | | <source lang="xml"> | ||
+ | <ThingDef ParentName="BasePawn"> | ||
+ | <defName>Human</defName> | ||
+ | <label>human</label> | ||
+ | |||
+ | <!-- irrelevant nodes omitted --> | ||
+ | |||
+ | <recipes> | ||
+ | <li>ExciseCarcinoma</li> | ||
+ | <li>AdministerMechSerumHealer</li> | ||
+ | <li>RemoveBodyPart</li> | ||
+ | <li>Euthanize</li> | ||
+ | <li>Anesthetize</li> | ||
+ | <li>CureScaria</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">Vasectomy</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">ReverseVasectomy</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">TubalLigation</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">ExtractOvum</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Royalty">CureBloodRot</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Royalty">CureAbasia</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">ExtractHemogenPack</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">BloodTransfusion</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">ImplantXenogerm</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">ImplantIUD</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">RemoveIUD</li> | ||
+ | <li MayRequire="Ludeon.RimWorld.Biotech">TerminatePregnancy</li> | ||
+ | </recipes> | ||
+ | |||
+ | <!-- irrelevant nodes omitted --> | ||
+ | |||
+ | </ThingDef> | ||
+ | </source> | ||
+ | | class="TutorialCodeTable-description" | | ||
+ | <code>MayRequire</code> is used in the Human [[Modding_Tutorials/ThingDef|ThingDef]] to set surgery recipes that are only relevant to specific DLCs. Without <code>MayRequire</code>, these would cause errors as the specified [[Modding_Tutorials/Defs|Defs]] only exist in their respective DLCs. | ||
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
Line 71: | Line 97: | ||
Note that the use of <code>MayRequire</code> on the list nodes of the <code><applyToRecipes></code> is technically unnecessary as the entire outcome node would not have loaded without [[Biotech]] active. | Note that the use of <code>MayRequire</code> on the list nodes of the <code><applyToRecipes></code> is technically unnecessary as the entire outcome node would not have loaded without [[Biotech]] active. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
Line 147: | Line 144: | ||
</div> | </div> | ||
− | == | + | == Stat Blocks == |
− | |||
− | |||
− | + | <code>MayRequire</code> can be used by any <code>StatModifier</code> list, which includes all <code>statBases</code>, <code>statOffsets</code>, <code>statFactors</code>, and <code>equippedStatOffsets</code> nodes: | |
<div class="TutorialTableWrapper"> | <div class="TutorialTableWrapper"> | ||
{| class="TutorialCodeTable" | {| class="TutorialCodeTable" | ||
− | ! XML | + | ! XML !! Description |
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
− | + | <ThingDef ParentName="ApparelMakeableBase"> | |
− | + | <defName>Apparel_Duster</defName> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | <ThingDef ParentName=" | ||
− | <defName> | ||
− | |||
− | <!-- irrelevant | + | <!-- irrelevant tags omitted --> |
− | < | + | <equippedStatOffsets> |
− | < | + | <SlaveSuppressionOffset MayRequire="Ludeon.RimWorld.Ideology">-0.05</SlaveSuppressionOffset> |
− | + | </equippedStatOffsets> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | </ | ||
− | |||
− | |||
+ | <!-- irrelevant tags omitted --> | ||
</ThingDef> | </ThingDef> | ||
</source> | </source> | ||
| class="TutorialCodeTable-description" | | | class="TutorialCodeTable-description" | | ||
− | <code>MayRequire</code> is used | + | <code>MayRequire</code> is used by several vanilla apparel [[Modding_Tutorial/ThingDef|ThingDef]]s to apply stats that are only relevant to DLCs, such as the [[Slavery|SlaveSuppressionOffset]] stat from [[Ideology]]. |
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
Line 229: | Line 188: | ||
</source> | </source> | ||
| class="TutorialCodeTable-description" | | | class="TutorialCodeTable-description" | | ||
− | <code>MayRequire</code> | + | <code>MayRequire</code> is used by several vanilla buildings such as the torch lamp to determine how much that particular building influences the overall style of the room it is in. This is also an [[Ideology]] feature. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
|} | |} | ||
Line 346: | Line 200: | ||
{| class="TutorialCodeTable" | {| class="TutorialCodeTable" | ||
! XML !! Description | ! XML !! Description | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
| <source lang="xml"> | | <source lang="xml"> | ||
Line 386: | Line 227: | ||
|} | |} | ||
</div> | </div> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
[[Category:Modding]] | [[Category:Modding]] | ||
[[Category:Modding tutorials]] | [[Category:Modding tutorials]] |