I'm having an issue with xpath stuff, trying to add items to a trader.

Started by Vas, May 03, 2019, 05:58:38 PM

Previous topic - Next topic

Vas

I'm not sure whats going wrong, there seems to be no way to activate patch related errors or logs of how the patch went through. Ive tried for two days now to try different things and nothing has worked so I give up and here I am. Personally I hate forums for communication, but I am not in any of the discords..

This is the item I am trying to add items to;
<?xml version="1.0" encoding="utf-8"?>
<Defs>

<TraderKindDef>
<defName>Orbital_MedicalGoods</defName>
<label>medical supplier</label>
<commonality>1</commonality>
<orbital>true</orbital>
<stockGenerators>
<li Class="StockGenerator_SingleDef">
<thingDef>Silver</thingDef>
<countRange>
<min>2000</min>
<max>4000</max>
</countRange>
</li>
<li Class="StockGenerator_SingleDef">
<thingDef>Cloth</thingDef>
<countRange>
<min>50</min>
<max>200</max>
</countRange>
</li>
<li Class="StockGenerator_SingleDef">
<thingDef>MedicineIndustrial</thingDef>
<countRange>
<min>100</min>
<max>250</max>
</countRange>
</li>
<li Class="StockGenerator_SingleDef">
<thingDef>MedicineUltratech</thingDef>
<countRange>
<min>25</min>
<max>75</max>
</countRange>
</li>
<li Class="StockGenerator_SingleDef">
<thingDef>Neutroamine</thingDef>
<countRange>
<min>250</min>
<max>750</max>
</countRange>
</li>
<li Class="StockGenerator_SingleDef">
<thingDef>Luciferium</thingDef>
<countRange>
<min>50</min>
<max>200</max>
</countRange>
</li>
<li Class="StockGenerator_SingleDef">
<thingDef>Penoxycyline</thingDef>
<countRange>
<min>100</min>
<max>300</max>
</countRange>
</li>
</stockGenerators>
</TraderKindDef>

</Defs>


This is the patch file;
<?xml version="1.0" encoding="utf-8" ?>
<Patch>

<Operation Class="PatchOperationSequence">
<success>Normal</success>
<operations>
<li Class="PatchOperationTest">
<xpath>/Defs/ThingDef[defName = "AntiparasiticalBooster"]</xpath> <!-- Test if this item exists -->
<success>Normal</success>
</li>
<li Class="PatchOperationAdd"> <!-- If the item above exists, add the below values to my trader's stock -->
<xpath>/Defs/TraderKindDef[defName = "Orbital_MedicalGoods"]/stockGenerators</xpath>
<value>
<li Class="StockGenerator_SingleDef">
<thingDef>AntiparasiticalBooster</thingDef>
<countRange>
<min>30</min>
<max>80</max>
</countRange>
</li>
</value>
</li>
</operations>
</Operation>

<Operation Class="PatchOperationSequence">
<success>Normal</success>
<operations>
<li Class="PatchOperationTest">
<xpath>/Defs/ThingDef[defName = "HerbalImmunityBooster"]</xpath> <!-- Test if this item exists -->
<success>Normal</success>
</li>
<li Class="PatchOperationAdd"> <!-- If the item above exists, add the below values to my trader's stock -->
<xpath>/Defs/TraderKindDef[defName = "Orbital_MedicalGoods"]/stockGenerators</xpath>
<value>
<li Class="StockGenerator_SingleDef">
<thingDef>HerbalImmunityBooster</thingDef>
<countRange>
<min>45</min>
<max>90</max>
</countRange>
</li>
</value>
</li>
</operations>
</Operation>

<Operation Class="PatchOperationSequence">
<success>Normal</success>
<operations>
<li Class="PatchOperationTest">
<xpath>/Defs/ThingDef[defName = "ConcentratedImmunityBooster"]</xpath> <!-- Test if this item exists -->
<success>Normal</success>
</li>
<li Class="PatchOperationAdd"> <!-- If the item above exists, add the below values to my trader's stock -->
<xpath>/Defs/TraderKindDef[defName = "Orbital_MedicalGoods"]/stockGenerators</xpath>
<value>
<li Class="StockGenerator_SingleDef">
<thingDef>ConcentratedImmunityBooster</thingDef>
<countRange>
<min>20</min>
<max>60</max>
</countRange>
</li>
</value>
</li>
</operations>
</Operation>

</Patch>


Essentially, I am trying to make it add those items to the shop list only if that person's mod is detected. The patch system is confusing to me, I'd rather use C# but I don't know how to code.
Click to see my steam. I'm a lazy modder who takes long breaks and everyone seems to hate.

LWM

You probably want your Sequence operations to be <success>Always</success>: this way, even if the first one of the sequence - that is, the test - fails, the entire thing is still considered a success.

Otherwise, if the item mod is not enabled, the first step of the sequence fails, and then the patch operation reports an error.

Generally, the debug log (~key) lists patch operation errors, and you can click on a line to get more details (which often gives you a good idea where the error is).

--LWM

Vas

If any of them are considered a failure however, thats a bad thing and means there is something wrong.

Edit;
Also, I know how to pen the debug log. There are no patch operation errors. There's no patch information here at all. Only comment lines talking about other mods patch jobs succeeding.
Click to see my steam. I'm a lazy modder who takes long breaks and everyone seems to hate.

LWM

Not necessarily.  Not having Combat Extended installed is a good thing, as far as *I* am concerned.  But for a PatchOperationTest, it's still a failed operation.

You're not seeing any errors in the debug log?  What, exactly, is the problem you are experiencing?

--LWM

Vas

Not sure where "Combat Extended" comes in at, but ok.

What I am expecting to see, is that my medical supply ship is modified to have the herbal boosters added to its stock.
What is happening, is nothing, those items are not added to the stock. I'll switch them to "always" just to check, but I doubt it'll do anything.

I shared the XML file my patch intends to patch, and the patch contents here so that you can see what I am trying to modify with my patch.

This is the mod I am trying to detect items from, and add them to my trade ship if the exist:
https://steamcommunity.com/sharedfiles/filedetails/?id=962926505
Click to see my steam. I'm a lazy modder who takes long breaks and everyone seems to hate.

LWM

Quote from: Vas on May 04, 2019, 06:16:44 PM
Not sure where "Combat Extended" comes in at, but ok.

Oh, I'm sorry - wasn't being clear.  I have several patch operations for compatibility with Combat Extended; I don't use it myself.  So the patch operation overall is a success, even if the "find combat extended" part fails.  I ended up going with a different approach, come to look at it again: https://github.com/lilwhitemouse/RimWorld-LWM.DeepStorage/blob/master/_Mod/LWM.DeepStorage/Patches/Compatibility_CombatExended.xml

So if there IS an error, it still shows up as an error message.

That might be an approach for you.

--LWM


LWM

A thought:

If you install my Deep Storage mod (or some of Mehni's mods, or many others' I'm sure), we have added a "LWM.DeepStorage.PatchMessage" (or PatchOperationLog or whatever) that spits out a message when it's invoked*.  If you use such a mod, you can piggyback off it and make sure your patches are actually running.

* - unless the author is either perverse or ...perverse.  In which case it might do weird unintended things that will cause giant space gophers** to eat your game.  Mine is not perverse :p
** - ...giant space gophers...new mod idea!