Ludeon Forums

RimWorld => Mods => Help => Topic started by: alexiltabaccaio on October 09, 2019, 09:37:36 AM

Title: A really nooby question about modcheck
Post by: alexiltabaccaio on October 09, 2019, 09:37:36 AM
Hi folks. I'm playing Rimworld from years now, and I decided to give my contribution with a patch (https://steamcommunity.com/sharedfiles/filedetails/?id=1884700025&searchtext=chains).

The code is really simple.

<?xml version="1.0" encoding="utf-8" ?>
<Patch>
        <Operation Class="PatchOperationReplace">
      <xpath>Defs/ThingDef[defName="Smokepit"]/costList</xpath>
      <value>
         <costList>
            <Owl_Firewood>10</Owl_Firewood>
         </costList>
      </value>
   </Operation>
</Patch>   

but i started to program today and i need to know how to ask rimworld to not make errors in menu screen if the patch is started without the mod to which it should be attached.
I read about modcheck, but I don't know what to do. Sorry about the banality of the post.

===================================================

After a few hours, I've come to this point.

<?xml version="1.0" encoding="utf-8" ?>
<Patch>
   <Operation Class="PatchOperationSequence">
      <success>Always</success>
      <operations>
         <li Class="ModCheck.AND">
            <tests>
            <li Class="ModCheck.isModLoaded">
               <modName>Simple Chains: Lumber</modName>
               <success>Invert</success>
            </li>
            <li Class="ModCheck.isModLoaded">
               <modName>Smoked meat</modName>
               <MessageSuccess>SC:L Smoked Meat: Check</MessageSuccess>
            </li>

            </tests>
         </li>
   
<!-- Smokepit -->
   
               <li Class="PatchOperationReplace">
                  <xpath>Defs/ThingDef[defName="Smokepit"]/costList</xpath>
                      <value>
                         <costList>
                            <Owl_Firewood>10</Owl_Firewood>
                         </costList>
                      </value>
               </li>
      </operations>
   </Operation>
</Patch>


Surely some of you will be laughing. and rightly still can't make it work. i hope to be enlightened by some of you.
Title: Re: A really nooby question about modcheck
Post by: LWM on October 09, 2019, 04:48:20 PM
Take a look at how I did it in any of these:

https://github.com/lilwhitemouse/RimWorld-LWM.DeepStorage/tree/master/_Mod/LWM.DeepStorage/Patches

Basically, you don't want Sequence or anything, you want to use vanilla's PatchOperationFindMod
Title: Re: A really nooby question about modcheck
Post by: alexiltabaccaio on October 09, 2019, 05:20:27 PM
oh man.. it works!!! Thanks a lot!!