XML Patch Help, Please

Started by Vakari, March 04, 2020, 04:20:57 PM

Previous topic - Next topic

Vakari

Posted a while back on an apparently dead thread, so wondering if anyone here can help me with an XML Patch noob question:

Is there a better way to combine two different changes to the same Def without two separate PatchReplace operations?  Here is what works, but is there a better way to do this?  (I tried just not pointing to /color or /colorTwo in the xpath, but it never worked.)

<Patch>
   <Operation Class="PatchOperationReplace">
      <xpath>/Defs/ThingDef[defName="MineableUranium"]/graphicData/color</xpath>
      <value>
         <color>(255,249,105)</color>
      </value>
   </Operation>
   <Operation Class="PatchOperationReplace">
      <xpath>/Defs/ThingDef[defName="MineableUranium"]/graphicData/colorTwo</xpath>
      <value>
         <colorTwo>(240,178,17)</colorTwo>
      </value>
   </Operation>
</Patch>


Thank you!

LWM

You could replace the entire graphicData?  But that's probably a bad idea.

Someone made a mod that allowed more complex node manipulation that I think included subNodes?

But in vanilla, no, you've got it.

Vakari

Quote from: LWM on March 04, 2020, 11:33:27 PM
You could replace the entire graphicData?  But that's probably a bad idea.

Someone made a mod that allowed more complex node manipulation that I think included subNodes?

But in vanilla, no, you've got it.

Thank you so much for the reply!  I really appreciate the help :)

LWM

Is this, perhaps, "Make Uranium Green?"

Vakari

#4
Quote from: LWM on March 05, 2020, 10:54:51 PM
Is this, perhaps, "Make Uranium Green?"

Sorry, I had to look that up.  No, I haven't tried that mod.  I did this for myself, unpublished.  This recolor is similar-looking to a bright yellow-colored Carnotite, although those colors can vary in shades of yellow to more yellowish-green.  I first made this little mod for myself by simply overwriting the entire def, but I wanted to know how to patch things like this that have to two almost identical element paths, and the solution I came up with just seemed clunky.  It worked, but I wasn't sure if I could merge the two somehow., make a more elegant patch operation.  It's all kind of new to me still, so I'm learning as I go.  In fact, the first recolor was the first "mod" I've ever made, and it was to help teach myself XML.  :)

Sorry for the long reply, but thanks again for the help :)!

LWM

Clearly you should release it on Steam as "Make Uranium Yellowish"!

;D

Congrats and yay :)