(Solved I am idort) My patching is failing and it isn't telling me why.

Started by Holgast, April 25, 2019, 05:18:27 AM

Previous topic - Next topic

Holgast

I thought I could try making a simple text replace mod but it doesn't seem to be working. Please let me know what  I am doing wrong.

<?xml version="1.0" encoding="utf-8" ?>

<Patch>


<Operation Class="PatchOperationReplace">
<xpath>/Defs/Drugs/Luciferium/ThingDef[defName = "DrugPillBase"]/label</xpath>
<value>
  <label>peanut butter sandwich</label>
</value>
</Operation>


<Operation Class="PatchOperationReplace">
<xpath>/Defs/Drugs/Luciferium[defName = "Hediffdef"]/label</xpath>
<value>
  <label>peanut butter sandwiches</label>
</value>
</Operation>

<Operation Class="PatchOperationReplace">
<xpath>/Defs/Drugs/Luciferium[defName = "DrugAddictionNeedBase"]/description</xpath>
<value>
<description>description</description>
</value>
</Operation>

<Operation Class="PatchOperationReplace">
<xpath>/Defs/Drugs/Luciferium[defName = "ChemicalDef"]/label</xpath>
<value>
  <label>peanut butter sandwich</label>
</value>
</Operation>

<Operation Class="PatchOperationReplace">
<xpath>/Defs/Drugs/Luciferium[defName = "DrugAddictionNeedBase"]/label</xpath>
<value>
  <label>peanut butter sandwiches</label>
</value>
</Operation>

<Operation Class="PatchOperationReplace">
<xpath>/Defs/Drugs/Luciferium[defName = "AddictionBase"]/label</xpath>
<value>
  <label>peanut butter sandwiches need</label>
</value>
</Operation>

<Operation Class="PatchOperationReplace">
<xpath>/Defs/Drugs/Luciferium[defName = "DrugPillBase"]/description</xpath>
<value>
<description>description</description>
</value>
</Operation>



</Patch>

Mehni

For a text replace mod, you could/should use RimWorld's translation tools.

Here's an (older) mod that renames Smokeleaf to Space weed. While details may have changed, the pattern still holds.

As to your XPath:
QuoteA common misconception is trying to account for file paths. The file path is completely irrelevant to the expression you're writing. XPath is used to search XML content, not files themselves.

But forget about the XPath: it's not the right tool for the job. Use the translation system.

Holgast

I recall looking at that one specifically but it didn't work out for me, I guess because the file structure changed.

I also tried it with the directory from the github but it looks like that hasn't been updated. Trying it again with the file structure from the game files.

edit: ok I tried that and it isn't making any changes, which was the problem I originally had. I also looked at the mod that renames Healroot to Xerigium and it does use the patch function

my folder is at \...\RimWorld\Mods\modname\Languages\English\Defs\Drugs\Luciferium.xml and it is

<?xml version="1.0" encoding="UTF-8"?>
<LanguageData>
<DrugPillBase.label>peanut butter sandwich</DrugPillBase.label>
<DrugPillBase.description>description</DrugPillBase.description>
<DrugAddictionNeedBase.label>peanut butter sandwich</DrugAddictionNeedBase.label>
<DrugAddictionNeedBase.description>description</DrugAddictionNeedBase.description>
<AddictionBase.label>peanut butter sandwiches need</AddictionBase.label>
</LanguageData>

Mehni

Look at the German translation then?

...\RimWorld\Mods\Core\Languages\German\DefInjected\ThingDef\Luciferium.xml

<?xml version="1.0" encoding="UTF-8"?>
<LanguageData>
 
  <!-- EN: luciferium -->
  <Luciferium.label>Luziferium</Luciferium.label>
  <!-- EN: Take {0} -->
  <Luciferium.ingestible.ingestCommandString>Nimm Luziferium ein.</Luciferium.ingestible.ingestCommandString>
  <!-- EN: Taking {0}. -->
  <Luciferium.ingestible.ingestReportString>Nimmt Luziferium ein.</Luciferium.ingestible.ingestReportString>
 
</LanguageData>


DrugPillBase is an XML thing; you don't need that. It doesn't get put into the game. That attribute is a reference to an XML template.

Holgast

Okay, I will look at that. I had been using the directory list under Core because the .txt in the English folder says 'the default English data is in the main XML data for the core mod.' However it does also say to refer to the German one...sigh I guess I got confused.

It looks like I didn't put all my folders into /DefInjected/ for some reason. That may be the problem. Let me try it again now.

edit: Yep that was it...I knew it was something simple. I definitely had some reason for putting those other folders outside of DefInjected. I was probably looking at an older folder layout.