-
Notifications
You must be signed in to change notification settings - Fork 2
TweakDef
Neronix17 edited this page Sep 10, 2023
·
2 revisions
TweakDefs are the main defs used to add a setting, you can store one of three values in each one, a bool, float or int, which can be used directly by the appropriate PatchOperation equivalent to apply the value it is currently set to.
Example TweakDef set up for a Bool value:
<TweaksGalore.TweakDef>
<defName>Tweak_BoomalopesBleedChemfuel</defName>
<label>Boomalopes Bleed Chemfuel</label>
<description>Changes the blood def from boomalopes and boomrats to be chemfuel puddles instead.</description>
<tweakType>Bool</tweakType> <!-- Sets how the TweakDef will be read by the code. -->
<defaultValue>false</defaultValue> <!-- Only needs the defaultValue set to either true or false, and it's ready. -->
<section>TweakSection_Vanilla_General</section>
</TweaksGalore.TweakDef>TweakDef set up for a Float value:
<TweaksGalore.TweakDef>
<defName>Tweak_SkillLossMultiplier</defName>
<label>Skill Loss Multiplier</label>
<description>Multiplier on rate of skill loss.</description>
<tweakType>Float</tweakType> <!-- Sets how the TweakDef will be read by the code. -->
<formatting>
<percentage>true</percentage>
<!-- Tells the settings screen to display it as a percentage
This only works for Float values. -->
</formatting>
<defaultValue>1.0</defaultValue> <!-- The defaultValue now reads it as a float because of tweakType -->
<floatRange>0.0~2.0</floatRange> <!-- Sets the outer limits of what the value can be set to (min~max) -->
</TweaksGalore.TweakDef>TweakDef set up for a Int value:
<TweaksGalore.TweakDef>
<defName>Tweak_MechanitorBandwidthBase</defName>
<label>Bandwidth Base</label>
<description>Controls the initial bandwidth all Mechanitors have.</description>
<tweakType>Int</tweakType>
<defaultValue>6</defaultValue>
<intRange>1~30</intRange>
<subSection>TweakSubSection_Biotech_MechanitorTweaks</subSection>
</TweaksGalore.TweakDef>You've probably noticed that <section> and <subSection> are a thing, this just tells it what def of either of those to display it under, you can do that in the TweakDef or you can list the defNames of the tweaks in the TweakSectionDef/TweakSubSectionDef, both options have the same result, it's up to you which you want to do.