Devilstrand - Mature and Immature

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

Previous topic - Next topic

jabbamonkey

I am recreating the graphics for the plant Devilstand (and other plants).  Some have mature and immature designations. Right now I setup the following folder structure and file names in my mod...

/Textures/Things/Plant/devilstrand/Devilstrand.png
/Textures/Things/Plant/devilstrandimmature/Devilstrand.png

The original source artwork is located in...

/Textures/Things/Plant/devilstrand/Devilstrand.png
(same as my designation above, so this should just replace the image)

But, either way, the game doesn't show the mature image (which is the same as the source) or immature image (which, I assume, may need some changes to the defs).

If someone could, let me know how to deal with plant graphic changes...

CannibarRechter


I've been able to get plant, immature, and leafless all working. Look in this thread here:

https://ludeon.com/forums/index.php?topic=35292.msg361324#msg361324

Also, you can download Vegetable Garden as a reference (that's how I learned).
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

Distman

Use these tags to get leafless and immature graphics to work:
<leaflessGraphicPath>
<immatureGraphicPath>

jabbamonkey

Quote from: Distman on August 29, 2017, 11:22:54 AM
Use these tags to get leafless and immature graphics to work:
<leaflessGraphicPath>
<immatureGraphicPath>

I'm assuming that leafless doesn't relate to plants, like devilstrand ... since leafless is meant for winter, correct?  So, most plants (unless unique) die in winter... right?

Any idea why my original graphic isn't showing? I replaced the default devilstrand graphic...

jabbamonkey

I added the following to my mods patch file...

   <Operation Class="PatchOperationInsert"> <!-- "Adding immatureGraphicPath to PlantDevilstrand" -->
<xpath>/ThingDefs/ThingDef[DefName = "PlantDevilstrand"]/graphicData/graphicClass</xpath>
<value>
<immatureGraphicPath>Things/Plant/Devilstrandimmature/</immatureGraphicPath>
</value>
</Operation>


...but I keep getting an error. Can anyone instruct me on how to fix the code above?

Distman

You are adding the tag to wrong node.
It should be under plant.

<xpath>/ThingDefs/ThingDef[DefName = "PlantDevilstrand"]/plant</xpath>

Quote from: jabbamonkey on August 29, 2017, 02:11:21 PM
I added the following to my mods patch file...

   <Operation Class="PatchOperationInsert"> <!-- "Adding immatureGraphicPath to PlantDevilstrand" -->
<xpath>/ThingDefs/ThingDef[DefName = "PlantDevilstrand"]/graphicData/graphicClass</xpath>
<value>
<immatureGraphicPath>Things/Plant/Devilstrandimmature/</immatureGraphicPath>
</value>
</Operation>


...but I keep getting an error. Can anyone instruct me on how to fix the code above?

Distman

Quote from: jabbamonkey on August 29, 2017, 01:30:30 PM
I'm assuming that leafless doesn't relate to plants, like devilstrand ... since leafless is meant for winter, correct?  So, most plants (unless unique) die in winter... right?

All plants get leafless and die when temperature is out of range, if the <dieIfLeafless> tag is set to true.

jabbamonkey

Quote from: Distman on August 29, 2017, 02:57:28 PM
You are adding the tag to wrong node.
It should be under plant.

Thanks Distman. I tried the change that you recommended... but am getting the attached error...

[attachment deleted by admin: too old]

CannibarRechter

Here's how you would CHANGE corn:

   <Operation Class="PatchOperationReplace">
      <xpath>*/ThingDef[defName = "PlantCorn"]/graphicData/texPath</xpath>
      <value><texPath>Items/Corn</texPath></value>
   </Operation>
   <Operation Class="PatchOperationReplace">
      <xpath>*/ThingDef[defName = "PlantCorn"]/plant/immatureGraphicPath</xpath>
      <value><immatureGraphicPath>Items/Immature/Corn</immatureGraphicPath></value>
   </Operation>   

Here's how you would change Devilistrand:


   <Operation Class="PatchOperationReplace">
      <xpath>*/ThingDef[defName = "PlantDevilstrand"]/graphicData/texPath</xpath>
      <value><texPath>Items/Devilstrand</texPath></value>
   </Operation>
   <Operation Class="PatchOperationAdd">
      <xpath>*/ThingDef[defName = "PlantCorn"]/plant</xpath>
      <value><immatureGraphicPath>Items/Immature/Devilstrand</immatureGraphicPath></value>
   </Operation>

This of course is assuming paths for textures in a different mod. Note I did not use "insert" I used Add. I think there is a variation of insert that could work equally well, but the Add doesn't need you to find a sibling to match, you just add, so I think the Add is better. Now, if for some reason, you want to replace if present, but add if not, that's what the test/sequences are for, but that's a subject for a different day.
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 August 29, 2017, 07:45:16 PM
<value><texPath>Items/Corn</texPath></value>
...
<immatureGraphicPath>Items/Immature/Corn</immatureGraphicPath>
...
<value><texPath>Items/Devilstrand</texPath></value>
...
<immatureGraphicPath>Items/Immature/Devilstrand</immatureGraphicPath>

The four paths that you provide (quoted above)... they will need to match the path to my images, correct?  So, if my image paths are:
Textures\Things\Plant\CornImmature\CornPlantA.png and Textures\Things\Plant\CornPlant ... then corn should be:

<value><texPath>Things/Plant/CornPlant</texPath></value>
...
<immatureGraphicPath>Things/Plant/CornImmature</immatureGraphicPath>


and if my devilstrand paths are Textures\Things\Plant\DevilstrandImmature and Textures\Things\Plant\Devilstrand, then devilstrand would be...

<value><texPath>Things/Plant/Devilstrand</texPath></value>
...
<immatureGraphicPath>Things/Plant/DevilstrandImmature</immatureGraphicPath>


Right? Or am I missing something?

CannibarRechter

#10
They need to have the path to the directory your image is in. This is true of all Graphics_Random assets. So, this path:

Items/Immature/Corn

... should be the path to a directory called corn. Inside the directory, there would be CornA.png. Note that  in theory there could also be a CornB.png, CornC.png, etc. Note that whatever you call corn in the mature corn directory, you must also call corn in the immature directory, and there must be a 1:1 match. The A17 texture dump is misleading in this way (it does not pull out the names of files from the core assets correctly!).

One thing I have noted -- and I don't know if this is just an error on my part -- the game seems to not like a different top level directory name than ones it already knows. I could be wrong about that, but I've had trouble making textures work where the FIRST directory is something random, like "mystuff" or whatever.
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

Ok. Got the corn and devilstrand working (Thank you very much!). Think I can get the rest of the BASIC crops to work...

But, I also want to change out the graphics in the T-Mod Extended Crops Mod (carrots and tomatoes). Can I do this in my mod ... or do I have to make the modifications in T's mod?

I tried the following (based on the devilstrand example), but it didn't work (all I see are red X boxes)...

<Operation Class="PatchOperationReplace">
      <xpath>*/ThingDef[defName = "PlantTomato"]/graphicData/texPath</xpath>
      <value><texPath>Things/Plant/Tomato</texPath></value>
   </Operation>   
   <Operation Class="PatchOperationAdd">
      <xpath>*/ThingDef[defName = "PlantTomato"]/plant</xpath>
      <value><immatureGraphicPath>Things/Plant/TomatoImmature</immatureGraphicPath></value>
   </Operation>
   
   <Operation Class="PatchOperationReplace">
      <xpath>*/ThingDef[defName = "PlantCarrot"]/graphicData/texPath</xpath>
      <value><texPath>Things/Plant/Carrot</texPath></value>
   </Operation>   
   <Operation Class="PatchOperationAdd">
      <xpath>*/ThingDef[defName = "PlantCarrot"]/plant</xpath>
      <value><immatureGraphicPath>Things/Plant/CarrotImmature</immatureGraphicPath></value>
   </Operation>



CannibarRechter

You need to learn about PatchOperationSequence. It's one of the things documented near the end of Zhentar's patch operation guide. I have an untested example I'm looking at right now. In short, though, there are cases where you want to do a patch ONLY if an xpath query is true (such as a def existing) or sometimes ONLY if its false (such as a def not existing). I have one that tests to see if the TilledSoil is defined, and if it is, replaces it with a different texture. Basically just what you want. I don't know if it works though, so standby and I'll post it in a bit.
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

CannibarRechter

Here you go. Here's a working mod patch that detects if the TilledSoil mod has defined its def, and overrides its texture:

<Patch>

<Operation Class="PatchOperationSequence">
   <success>Always</success>
   <operations>
    <li Class="PatchOperationTest">
      <xpath>*/TerrainDef[defName = "GT_SoilTilled"]</xpath>
      <!-- <success>Invert</success> ONLY use if you want it to execute if the xpath FAILS -->
    </li>   
   <li Class="PatchOperationReplace">
      <xpath>*/TerrainDef[defName = "GT_SoilTilled"]/texturePath</xpath>
      <value><texturePath>Items/Terrain/TilledSoil</texturePath></value>
   </li>
   </operations>
</Operation>

</Patch>

I believe you can do multiple things after the Test, not just the one, so you can sequence them together. For example, if I were detecting if a special plant existed, I could replace the main, immature, and leafless textures all as independence patch operations in one sequence, with just the one test.
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 August 30, 2017, 08:15:38 PM
I believe you can do multiple things after the Test, not just the one, so you can sequence them together. For example, if I were detecting if a special plant existed, I could replace the main, immature, and leafless textures all as independence patch operations in one sequence, with just the one test.

Ok, this is going a bit over my head. I know a little PHP, by my programming knowledge is limited.  I'm used to simple conditional statements (if, else). Sorry to be such a noob, but can you explain how this works...

Which part of the code represents the "IF" statement in the code?

And do you have a link to Zhentar's patch operation guide? That might help me...