Devilstrand - Mature and Immature

Started by jabbamonkey, August 29, 2017, 08:37:12 AM

Previous topic - Next topic

skullywag

PatchOperationTest is IF:

IF */TerrainDef[defName = "GT_SoilTilled"] exists THEN PatchOperationReplace
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?


jabbamonkey

Quote from: kaptain_kavern on August 31, 2017, 11:15:31 AM
Patch operation guide : https://gist.github.com/Zhentar/4a1b71cea45b9337f70b30a21d868782

Ok, I tried following the tutorial...  I managed to put together this...

<Operation Class="PatchOperationSequence">
  <success>Always</success>
  <operations>
    <li Class="PatchOperationTest">
      <xpath>*/ThingDef[defName = "PlantTomato"]/graphicData/texPath</xpath>
      <success>Invert</success>
    </li>
<li Class="PatchOperationAdd">
      <xpath>*/ThingDef[defName = "PlantTomato"]/graphicData/texPath</xpath>
      <value>
<immatureGraphicPath>Things/Plant/TomatoImmature</immatureGraphicPath>
      </value>
    </li>
  </operations>
</Operation>


This is still not showing the revised texture, and also not showing the immature version. Any ideas how I fix this?  At least the graphics aren't showing up like red boxes anymore...

The tutorial didn't explain what the  <success>Always</success> meant. Or the <success>Invert</success> ... ? 

CannibarRechter

My previous comment explains the invert. Remove it. That's why I commented it for you
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

jabbamonkey

When I remove the invert, I started getting the following error message when I start the game...

In addition, the new graphics don't show up at all. I don't even see a red box with an X ... it's as if the PNG images are all transparent...

[attachment deleted by admin: too old]

CannibarRechter

#20
Are you attempting to retexture PlantTomato from VeggieGarden? If so, then you are adding an immatureGraphicPath when one already exists, and you want to replace it. That's mistake 1. Mistake two is that you can't add an immatureGraphicPath to a texPath. Mistake 3 is that immatureGraphicPath can't live under the graphicData section, it must be in plant. The corrected XML is as follows:


<Operation Class="PatchOperationSequence">
  <success>Always</success>
  <operations>
    <li Class="PatchOperationTest">
      <xpath>*/ThingDef[defName = "PlantTomato"]/plant/immatureGraphicPath</xpath>
    </li>
<li Class="PatchOperationReplace">
      <xpath>*/ThingDef[defName = "PlantTomato"]/plant/immatureGraphicPath</xpath>
      <value>
<immatureGraphicPath>Things/Plant/TomatoImmature</immatureGraphicPath>
      </value>
    </li>
  </operations>
</Operation>


Use replace to replace something. Use add to add something. When you add, you will add "beneath" the queried item. When you replace you replace "at" the queried item. In the case of a replace, the XML is inclusive of the replacement. So if you say "replace" foo, the value must be <foo>something</foo>.

Hope this helps.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

jabbamonkey

Quote from: CannibarRechter on September 03, 2017, 05:57:19 AM
Use replace to replace something. Use add to add something. When you add, you will add "beneath" the queried item. When you replace you replace "at" the queried item. In the case of a replace, the XML is inclusive of the replacement. So if you say "replace" foo, the value must be <foo>something</foo>.

Hope this helps.

I'm, actually modifying T-Mods Extended Crops (which has Tomatoes) ... and that mod doesn't have an immature image yet (only the default regular version). So replace shouldn't work for the immature graphic.

Also, looking at the code above ... there is no mention of replacing the original graphic texture. In T-Mods, the path to the original is in a different place than my new tomato texture, so I also need to "replace" the original graphic.

CannibarRechter

#22
Quotethe path to the original is in a different place than my new tomato texture

Then what you are going to need to do is REMOVE the first, and ADD the second. You cannot combine remove/add that way. So: 1) detect the presence of the mod: 2) remove the element you don't like, 3) add the element you need. You can do this in a longer sequence, you don't need to keep repeating tests. If you need to replace elements after the test, you can do that, too.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

jabbamonkey

I tried the replace ... while that didn't get me any errors, it still got me the red X box for the graphics. So, I tried to remove and add (and then add the immature). This got me some more errors...

<Operation Class="PatchOperationSequence">
  <success>Always</success>
  <operations>
    <li Class="PatchOperationTest">
      <xpath>*/ThingDef[defName = "PlantTomato"]/graphicData/texPath</xpath>
    </li>
   <li Class="PatchOperationRemove">
      <xpath>*/ThingDef[defName = "PlantTomato"]/graphicData/texPath</xpath>
      <value>
      <texPath>Things/TomatoPlant</texPath>
     </value>
   </li>
   <li Class="PatchOperationAdd">
      <xpath>*/ThingDef[defName = "PlantTomato"]/graphicData/texPath</xpath>
      <value>
      <texPath>Things/Plant/Tomato</texPath>
     </value>
   </li>
   <li Class="PatchOperationAdd">
      <xpath>*/ThingDef[defName = "PlantTomato"]/plant</xpath>
      <value>
      <immatureGraphicPath>Things/Plant/TomatoImmature</immatureGraphicPath>
      </value>
    </li>
  </operations>
</Operation>


Just some info... the path to T-Mods original tomato graphic is... T-ExpandedCrops/Textures/Things/TomatoPlant.png (so am I using the correct path for the REMOVE?) And, for the base texture ADD, my new path is JabbaGraphics/Textures/Things/Plant/Tomato/TomatoPlant.png ... Is that path above correct? And the second ADD path is JabbaGraphics/Textures/Things/Plant/TomatoImmature/TomatoPlant.png

CannibarRechter

You can use replace as long as it is exactly the same thing you are replacing. This below should work. I did two things to it: 1. I removed the value tags from the remove (it's literally removing what is cited, up to and INCLUDING texPath, the value tags do nothing), and then I removed the texPath from your add, because you can't add to that (because it's gone). While you don't need remove/add for this patch (I just read T's mod), I thought I would explain how you could make it work so you could understand remove/add better.

Your second add is good. If this doesn't work, I suspect something other than the patch.


<Operation Class="PatchOperationSequence">
  <success>Always</success>
  <operations>
    <li Class="PatchOperationTest">
      <xpath>*/ThingDef[defName = "PlantTomato"]/graphicData/texPath</xpath>
    </li>
   <li Class="PatchOperationRemove">
      <xpath>*/ThingDef[defName = "PlantTomato"]/graphicData/texPath</xpath>
   </li>
   <li Class="PatchOperationAdd">
      <xpath>*/ThingDef[defName = "PlantTomato"]/graphicData</xpath>
      <value>
      <texPath>Things/Plant/Tomato</texPath>
     </value>
   </li>
   <li Class="PatchOperationAdd">
      <xpath>*/ThingDef[defName = "PlantTomato"]/plant</xpath>
      <value>
      <immatureGraphicPath>Things/Plant/TomatoImmature</immatureGraphicPath>
      </value>
    </li>
  </operations>
</Operation>


Here's the shorter version:


<Operation Class="PatchOperationSequence">
  <success>Always</success>
  <operations>
    <li Class="PatchOperationTest">
      <xpath>*/ThingDef[defName = "PlantTomato"]/graphicData/texPath</xpath>
    </li>
   <li Class="PatchOperationReplace">
      <xpath>*/ThingDef[defName = "PlantTomato"]/graphicData/texPath</xpath>
      <value>
      <texPath>Things/Plant/Tomato</texPath>
     </value>
   </li>
   <li Class="PatchOperationAdd">
      <xpath>*/ThingDef[defName = "PlantTomato"]/plant</xpath>
      <value>
     <immatureGraphicPath>Things/Plant/TomatoImmature</immatureGraphicPath>
      </value>
    </li>
  </operations>
</Operation>

CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

jabbamonkey

Tried it... not getting any errors on load, but the graphics are red blocks again...

I uploaded my mod, and T-Epanded-Crops mod here:
http://classicgaming.cc/mods/rimworld/ModTest.zip

If you can, take a look. Let me know if I missed anything...

CannibarRechter

#26
This is what you want.


<Patch>

<Operation Class="PatchOperationSequence">
  <success>Always</success>
  <operations>
    <li Class="PatchOperationTest">
      <xpath>*/ThingDef[defName = "PlantTomato"]/graphicData/texPath</xpath>
    </li>
   <li Class="PatchOperationReplace">
      <xpath>*/ThingDef[defName = "PlantTomato"]/graphicData/texPath</xpath>
      <value>
      <texPath>Things/Plant/Tomato/TomatoPlant</texPath>
     </value>
   </li>
   <li Class="PatchOperationAdd">
      <xpath>*/ThingDef[defName = "PlantTomato"]/plant</xpath>
      <value>
     <immatureGraphicPath>Things/Plant/TomatoImmature/TomatoPlant</immatureGraphicPath>
      </value>
    </li>
  </operations>
</Operation>
   
</Patch>



So. The reason you were having a problem is that T's mod makes plants Graphic_Single. That's unusual, and not the way a plant is normally done (see the Core). In a Graphic_Single texture, the texture is the "entire path" all the way up to and including the file name, but leaving off the .png.

Graphic_Random, and Graphic_Multi are different. Graphic_Random wants a path to the directory your images are in, but doesn't want the image name in the path. This is tricky. Whenever you have Graphic_Random, the game just automatically loops and picks up the names of the files. In that case, since you never actually wrote the names in XML, the game has no choice but to assume that the name of the image in each directory you use is the same. If the main graphic is called "SomethingA," then the game just assumes it's called "SomethingA" in each directory you use. It HAS TO, if you think about it...

--> In a Graphics_Single path, you can name your images whatever you want, but all paths must point to the IMAGE.

--> In a Graphics_Random path, you can name your images whatever you want, but all paths must point to the PARENT DIRECTORY, and all image names must agree across default ("mature"), immature, and leafless directories. All directories are to the PARENT in each case.

p.s. I like your graphics, man. Nice job.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

jabbamonkey

Quote from: CannibarRechter on September 03, 2017, 05:33:37 PM
This is what you want.

IT WORKS!  Thanks alot. I would have never figured it out on my own. I'll let you know when the next complete rollout it.

CannibarRechter

Your welcome, man. BTW, do you know about the "grow 1 day" command in the dev console? I see you are modding plant textures; it's very helpful to quickly see how things are working...
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects