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 71: Line 71:
  
 
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">
 
<DesignationCategoryDef>
 
  <defName>Zone</defName>
 
  <label>zone</label>
 
  <order>800</order>
 
  <specialDesignatorClasses>
 
    <li>Designator_Cancel</li>
 
    <li>Designator_Deconstruct</li>
 
    <li>Designator_ZoneAddStockpile_Resources</li>
 
    <li>Designator_ZoneAddStockpile_Dumping</li>
 
    <li>Designator_ZoneAdd_Growing</li>
 
    <li>Designator_ZoneDelete</li>
 
    <li>Designator_AreaHomeExpand</li>
 
    <li>Designator_AreaHomeClear</li>
 
    <li>Designator_AreaAllowedExpand</li>
 
    <li>Designator_AreaAllowedClear</li>
 
    <li>Designator_AreaBuildRoof</li>
 
    <li>Designator_AreaNoRoof</li>
 
    <li>Designator_AreaIgnoreRoof</li>
 
    <li>Designator_AreaSnowClearExpand</li>
 
    <li>Designator_AreaSnowClearClear</li>
 
    <li MayRequire="Ludeon.RimWorld.Biotech">Designator_AreaPollutionClearExpand</li>
 
    <li MayRequire="Ludeon.RimWorld.Biotech">Designator_AreaPollutionClearClear</li>
 
  </specialDesignatorClasses>
 
</DesignationCategoryDef>
 
</source>
 
| class="TutorialCodeTable-description" |
 
<code>MayRequire</code> is used in the DesignationCategoryDef for the "Zone" architect menu to add designators for pollution clearing areas.
 
 
|-
 
|-
 
| <source lang="xml">
 
| <source lang="xml">
Line 147: Line 118:
 
</div>
 
</div>
  
== Def References ==
+
=== Lists of Defs ===
  
<code>MayRequire</code> can be used on any field that references [[Modding_Tutorials/Defs|Defs]] by their <code>defName</code>, including single fields, lists, and special parsed lists such as stat blocks and item count lists.
+
Unlike other usages of <code>MayRequire</code>, lists of Defs have a special behavior: when used to filter lists of [[Modding_Tutorials/Defs|Defs]], <code>MayRequire</code> only serves to suppress cross-resolution errors if the targeted DLC or mod is not loaded. '''If RimWorld finds the targeted Def, it will be loaded into the list regardless of whether the specified DLC or mod is loaded or not.'''
 
 
'''Note''': When used in direct references or in a list of direct references, Def references have a special behavior in that <code>MayRequire</code> only serves to suppress cross-resolution errors if the targeted DLC or mod is not loaded. '''If RimWorld finds the targeted Def, it will be loaded into the list regardless of whether the specified DLC or mod is loaded or not.''' This does not apply to special parsed lists (see below).
 
  
 
<div class="TutorialTableWrapper">
 
<div class="TutorialTableWrapper">
 
{| class="TutorialCodeTable"
 
{| class="TutorialCodeTable"
 
! XML Example !! Description
 
! XML Example !! Description
|-
 
| <source lang="xml">
 
<LifeStageDef ParentName="HumanlikeAdolescent">
 
  <defName>HumanlikeBaby</defName>
 
  <label>baby</label>
 
 
  <!-- irrelevant nodes omitted -->
 
 
  <thinkTreeMainOverride MayRequire="Ludeon.RimWorld.Biotech">HumanlikeBaby</thinkTreeMainOverride>
 
  <thinkTreeConstantOverride MayRequire="Ludeon.RimWorld.Biotech">HumanlikeBabyConstant</thinkTreeConstantOverride>
 
 
  <!-- irrelevant nodes omitted -->
 
 
</LifeStageDef>
 
</source>
 
| class="TutorialCodeTable-description" |
 
<code>MayRequire</code> is used in human LifeStageDefs for Def references such as the ThinkTreeDefs for certain lifestages. These Defs only exist in the Biotech DLC, and thus must have errors suppressed if the DLC is not loaded.
 
 
|-
 
|-
 
| <source lang="xml">
 
| <source lang="xml">
Line 208: Line 160:
 
| class="TutorialCodeTable-description" |
 
| 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.
 
<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">
 +
<DesignationCategoryDef>
 +
  <defName>Zone</defName>
 +
  <label>zone</label>
 +
  <order>800</order>
 +
  <specialDesignatorClasses>
 +
    <li>Designator_Cancel</li>
 +
    <li>Designator_Deconstruct</li>
 +
    <li>Designator_ZoneAddStockpile_Resources</li>
 +
    <li>Designator_ZoneAddStockpile_Dumping</li>
 +
    <li>Designator_ZoneAdd_Growing</li>
 +
    <li>Designator_ZoneDelete</li>
 +
    <li>Designator_AreaHomeExpand</li>
 +
    <li>Designator_AreaHomeClear</li>
 +
    <li>Designator_AreaAllowedExpand</li>
 +
    <li>Designator_AreaAllowedClear</li>
 +
    <li>Designator_AreaBuildRoof</li>
 +
    <li>Designator_AreaNoRoof</li>
 +
    <li>Designator_AreaIgnoreRoof</li>
 +
    <li>Designator_AreaSnowClearExpand</li>
 +
    <li>Designator_AreaSnowClearClear</li>
 +
    <li MayRequire="Ludeon.RimWorld.Biotech">Designator_AreaPollutionClearExpand</li>
 +
    <li MayRequire="Ludeon.RimWorld.Biotech">Designator_AreaPollutionClearClear</li>
 +
  </specialDesignatorClasses>
 +
</DesignationCategoryDef>
 +
</source>
 +
| class="TutorialCodeTable-description" |
 +
<code>MayRequire</code> is used in the DesignationCategoryDef for the "Zone" architect menu to add designators for pollution clearing areas.
 +
|-
 +
|}
 +
</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">
 +
{| class="TutorialCodeTable"
 +
! XML !! Description
 +
|-
 +
| <source lang="xml">
 +
<ThingDef ParentName="ApparelMakeableBase">
 +
  <defName>Apparel_Duster</defName>
 +
 
 +
  <!-- irrelevant tags omitted -->
 +
 
 +
  <equippedStatOffsets>
 +
    <SlaveSuppressionOffset MayRequire="Ludeon.RimWorld.Ideology">-0.05</SlaveSuppressionOffset>
 +
  </equippedStatOffsets>
 +
 
 +
  <!-- irrelevant tags omitted -->
 +
</ThingDef>
 +
</source>
 +
| class="TutorialCodeTable-description" |
 +
<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 237:
 
</source>
 
</source>
 
| class="TutorialCodeTable-description" |
 
| class="TutorialCodeTable-description" |
<code>MayRequire</code> can be used in "special parsers" such as those for <code>statBases</code>. These are usually used to create shorthand notation wherein the node name is the <code>defName</code> and the value is the stat value. The vanilla torch lamp uses the <code>StyleDominance</code> stat from [[Ideology]] to affect the room it is placed in.
+
<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.
 +
|-
 +
|}
 +
</div>
 +
 
 +
== Optional Defs ==
 +
 
 +
<code>MayRequire</code> can be used to conditionally load entire Defs. This is far easier to use than the prior option of using [[Modding_Tutorials/PatchOperations|PatchOperations]] to inject new Defs.
 +
 
 +
<div class="TutorialTableWrapper">
 +
{| class="TutorialCodeTable"
 +
! XML !! Description
 +
|-
 +
| <source lang="xml">
 +
<ThingDef MayRequire="Ludeon.RimWorld.Ideology" ParentName="Brazier">
 +
  <defName>DarklightBrazier</defName>
 +
  <label>darklight brazier</label>
 +
  <description>A specially treated brazier that illuminates its surroundings with darklight and creates heat. These satisfy royal brazier requirements.</description>
 +
 
 +
  <!-- irrelevant content omitted -->
 +
 
 +
</ThingDef>
 +
</source>
 +
| class="TutorialCodeTable-description" |
 +
<code>MayRequire</code> is used to activate [[Royalty]]'s darklight brazier stat if [[Ideology]] is also loaded.
 
|-
 
|-
 
| <source lang="xml">
 
| <source lang="xml">
<ThingDef ParentName="ApparelMakeableBase">
+
<StatDef ParentName="MeditationFocusBase" MayRequireAnyOf="Ludeon.RimWorld.Royalty,Ludeon.RimWorld.Biotech">
   <defName>Apparel_Duster</defName>
+
   <defName>MeditationFocusGain</defName>
 +
  <label>meditation psyfocus gain</label>
 +
 
 +
  <!-- irrelevant content omitted -->
 
    
 
    
  <!-- irrelevant tags omitted -->
+
</StatDef>
 +
</source>
 +
| class="TutorialCodeTable-description" |
 +
<code>MayRequireAnyOf</code> is used to activate the MeditationFocusGain stat if either [[Royalty]] or [[Biotech]] is loaded.
 +
|-
 +
| <source lang="xml">
 +
<ThingDef ParentName="ApparelMakeableBase" MayRequireAnyOf="Ludeon.RimWorld.Royalty,Ludeon.RimWorld.Biotech">
 +
  <defName>Apparel_Cape</defName>
 +
  <label>cape</label>
 
    
 
    
   <equippedStatOffsets>
+
   <!-- irrelevant content omitted -->
    <SlaveSuppressionOffset MayRequire="Ludeon.RimWorld.Ideology">-0.05</SlaveSuppressionOffset>
 
  </equippedStatOffsets>
 
 
    
 
    
  <!-- irrelevant tags omitted -->
 
 
</ThingDef>
 
</ThingDef>
 
</source>
 
</source>
 
| class="TutorialCodeTable-description" |
 
| class="TutorialCodeTable-description" |
<code>equippedStatOffsets</code> is another example of a stat block. In this example, the vanilla [[Duster]] apparel has a [[Slavery|SlaveSuppressionOffset]] stat offset from [[Ideology]].
+
<code>MayRequireAnyOf</code> is used to activate the [[Cape]] apparel if either [[Royalty]] or [[Biotech]] is loaded.
 +
|-
 +
|}
 +
</div>
 +
 
 +
== Miscellaneous ==
 +
 
 +
The following are specific, non-standard usages of <code>MayRequire</code>. Some of these are technically lists with special parsing, some are fields that were coded specifically to accept the <code>MayRequire</code> attribute.
 +
 
 +
<div class="TutorialTableWrapper">
 +
{| class="TutorialCodeTable"
 +
! XML !! Description
 
|-
 
|-
 
| <source lang="xml">
 
| <source lang="xml">
Line 335: Line 386:
 
| class="TutorialCodeTable-description" |
 
| class="TutorialCodeTable-description" |
 
<code>MayRequire</code> must be used for xenotype references in <code>FactionDef</code> entries, as they only exist if [[Biotech]] is loaded.
 
<code>MayRequire</code> must be used for xenotype references in <code>FactionDef</code> entries, as they only exist if [[Biotech]] is loaded.
|-
 
|}
 
</div>
 
 
== Optional Defs ==
 
 
<code>MayRequire</code> can be used to conditionally load entire Defs. This is far easier to use than the prior option of using [[Modding_Tutorials/PatchOperations|PatchOperations]] to inject new Defs.
 
 
<div class="TutorialTableWrapper">
 
{| class="TutorialCodeTable"
 
! XML !! Description
 
|-
 
| <source lang="xml">
 
<ThingDef MayRequire="Ludeon.RimWorld.Ideology" ParentName="Brazier">
 
  <defName>DarklightBrazier</defName>
 
  <label>darklight brazier</label>
 
  <description>A specially treated brazier that illuminates its surroundings with darklight and creates heat. These satisfy royal brazier requirements.</description>
 
 
 
  <!-- irrelevant content omitted -->
 
 
</ThingDef>
 
</source>
 
| class="TutorialCodeTable-description" |
 
<code>MayRequire</code> is used to activate [[Royalty]]'s darklight brazier stat if [[Ideology]] is also loaded.
 
|-
 
| <source lang="xml">
 
<StatDef ParentName="MeditationFocusBase" MayRequireAnyOf="Ludeon.RimWorld.Royalty,Ludeon.RimWorld.Biotech">
 
  <defName>MeditationFocusGain</defName>
 
  <label>meditation psyfocus gain</label>
 
 
 
  <!-- irrelevant content omitted -->
 
 
 
</StatDef>
 
</source>
 
| class="TutorialCodeTable-description" |
 
<code>MayRequireAnyOf</code> is used to activate the MeditationFocusGain stat if either [[Royalty]] or [[Biotech]] is loaded.
 
|-
 
| <source lang="xml">
 
<ThingDef ParentName="ApparelMakeableBase" MayRequireAnyOf="Ludeon.RimWorld.Royalty,Ludeon.RimWorld.Biotech">
 
  <defName>Apparel_Cape</defName>
 
  <label>cape</label>
 
 
 
  <!-- irrelevant content omitted -->
 
 
 
</ThingDef>
 
</source>
 
| class="TutorialCodeTable-description" |
 
<code>MayRequireAnyOf</code> is used to activate the [[Cape]] apparel if either [[Royalty]] or [[Biotech]] is loaded.
 
|-
 
|}
 
</div>
 
 
== Miscellaneous ==
 
 
The following are specific, non-standard usages of <code>MayRequire</code> from official content XML:
 
 
<div class="TutorialTableWrapper">
 
{| class="TutorialCodeTable"
 
! XML !! Description
 
 
|-
 
|-
 
| <source lang="xml">
 
| <source lang="xml">

Please note that all contributions to RimWorld Wiki are considered to be released under the CC BY-SA 3.0 (see RimWorld Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Template used on this page: