Patching new pawn to pawnmakergroup

Started by XeoNovaDan, May 20, 2017, 10:35:08 AM

Previous topic - Next topic

XeoNovaDan

I've also just noticed that xPathing happens before new Def addition, it seems.

I've made a new PawnType in the Defs called TribalSlinger, which uses weapons with the Sling tag (i.e. the sling from my weapon mod), and I'm trying to use xPathing to add the new TribalSlinger to the pawnGroupMakers - but there's an error saying that TribalSlinger doesn't exist - despite the fact that it's definitely defined under Defs in the same mod.

SihvMan

#1
Quote from: XeoNovaDan on May 20, 2017, 10:35:08 AM
I've also just noticed that xPathing happens before new Def addition, it seems.

Are you putting the xpathing in the right location, with the right preface tags?

It should have a folder layout of

[About]
[Defs]
--*DefContainingSlingerPawn.xml
[Patches]
--*Patch.xml goes here
[Textures]


And the code in Patch.xml should be;

<Patch> <!--- Important! Not <Defs> -->
<Operation Class="PatchOperationAdd">
  <xpath>//FactionDef[defName = "Tribe"]/pawnGroupMakers/li[0]</xpath>
  <value>
    <PawnDefNameHere>123</PawnDefNameHere>
  </value>
</Operation>
</Patch>


By putting it in the Patches folder and prefacing with the <Patch> tag, the xpath stuff is added absolutely last, after <Defs> stuff is loaded.

Shinzy

Hey! I split this bit from the other thread cause it felt like the proper thing to do at this point! ;D
It might be there's typo in the Defname of your new pawn too Xeo

SihvMan

Quote from: Shinzy on May 20, 2017, 11:36:35 AM
Hey! I split this bit from the other thread cause it felt like the proper thing to do at this point! ;D

Oh! That's what happened! I thought I hallucinated slightly when my reply and the question both disappeared from the thread mid-edit.

Quote from: Shinzy on May 20, 2017, 11:36:35 AM
It might be there's typo in the Defname of your new pawn too Xeo

Definitely check this. When making my Bone Mod, I was frustrated for hours checking why I couldn't patch ArcticFox and ArcticWolf, only to discover I had accidentally typed ArticFox and Arcticwolf instead. Precise spelling and capitalization are important XeoNovaDan

XeoNovaDan


SihvMan

#5
Quote from: XeoNovaDan on May 20, 2017, 11:58:43 AM
AFAIK all dots are lined up OK

-sic-

The PatchOperationInsert should be PatchOperationAdd, because you're adding a child node to options.

If you used Insert, it would need
<xpath>//FactionDef[defName = "Tribe"]/pawnGroupMakers/li[0]/options/TribalChief</xpath>

XeoNovaDan

Just tried it, the following errors come up:


[Vanilla-friendly Weapon Expansion] Patch operation Verse.PatchOperationAdd(//FactionDef[defName = "Tribe"]/pawnGroupMakers/li[0]/options) failed
Verse.Log:Error(String) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Utility\Debug\Log\Log.cs:48)
Verse.PatchOperation:Complete(String) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Mods\PatchOperation.cs:62)
Verse.LoadedModManager:LoadAllActiveMods() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Mods\LoadedModManager.cs:84)
Verse.PlayDataLoader:DoPlayLoad() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Defs\Databases\PlayDataLoader.cs:92)
Verse.PlayDataLoader:LoadAllPlayData(Boolean) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Defs\Databases\PlayDataLoader.cs:32)
Verse.Root:<Start>m__853() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\Root\Root.cs:49)
Verse.LongEventHandler:RunEventFromAnotherThread(Action) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\LongEventHandler.cs:439)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__851() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\LongEventHandler.cs:353)

[Vanilla-friendly Weapon Expansion] Patch operation Verse.PatchOperationAdd(//FactionDef[defName = "Tribe"]/pawnGroupMakers/li[2]/options) failed
Verse.Log:Error(String) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Utility\Debug\Log\Log.cs:48)
Verse.PatchOperation:Complete(String) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Mods\PatchOperation.cs:62)
Verse.LoadedModManager:LoadAllActiveMods() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Mods\LoadedModManager.cs:84)
Verse.PlayDataLoader:DoPlayLoad() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Defs\Databases\PlayDataLoader.cs:92)
Verse.PlayDataLoader:LoadAllPlayData(Boolean) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Defs\Databases\PlayDataLoader.cs:32)
Verse.Root:<Start>m__853() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\Root\Root.cs:49)
Verse.LongEventHandler:RunEventFromAnotherThread(Action) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\LongEventHandler.cs:439)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__851() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\LongEventHandler.cs:353)


I'll definitely need to investigate the syntax.

SihvMan

Quote from: XeoNovaDan on May 20, 2017, 12:15:39 PM
Just tried it, the following errors come up:


[Vanilla-friendly Weapon Expansion] Patch operation Verse.PatchOperationAdd(//FactionDef[defName = "Tribe"]/pawnGroupMakers/li[0]/options) failed
Verse.Log:Error(String) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Utility\Debug\Log\Log.cs:48)
Verse.PatchOperation:Complete(String) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Mods\PatchOperation.cs:62)
Verse.LoadedModManager:LoadAllActiveMods() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Mods\LoadedModManager.cs:84)
Verse.PlayDataLoader:DoPlayLoad() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Defs\Databases\PlayDataLoader.cs:92)
Verse.PlayDataLoader:LoadAllPlayData(Boolean) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Defs\Databases\PlayDataLoader.cs:32)
Verse.Root:<Start>m__853() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\Root\Root.cs:49)
Verse.LongEventHandler:RunEventFromAnotherThread(Action) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\LongEventHandler.cs:439)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__851() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\LongEventHandler.cs:353)

[Vanilla-friendly Weapon Expansion] Patch operation Verse.PatchOperationAdd(//FactionDef[defName = "Tribe"]/pawnGroupMakers/li[2]/options) failed
Verse.Log:Error(String) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Utility\Debug\Log\Log.cs:48)
Verse.PatchOperation:Complete(String) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Mods\PatchOperation.cs:62)
Verse.LoadedModManager:LoadAllActiveMods() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Mods\LoadedModManager.cs:84)
Verse.PlayDataLoader:DoPlayLoad() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Defs\Databases\PlayDataLoader.cs:92)
Verse.PlayDataLoader:LoadAllPlayData(Boolean) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Defs\Databases\PlayDataLoader.cs:32)
Verse.Root:<Start>m__853() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\Root\Root.cs:49)
Verse.LongEventHandler:RunEventFromAnotherThread(Action) (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\LongEventHandler.cs:439)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__851() (at C:\Dev\RimWorld\Assets\Scripts\Verse\Global\LongEventHandler.cs:353)


I'll definitely need to investigate the syntax.

Try

<Patch> <!--- Important! Not <Defs> -->
  <Operation Class="PatchOperationAdd">
    <xpath>//FactionDef[defName = "Tribe"]/pawnGroupMakers/li[1]/options</xpath>

instead of

<Patch> <!--- Important! Not <Defs> -->
  <Operation Class="PatchOperationAdd">
    <xpath>//FactionDef[defName = "Tribe"]/pawnGroupMakers/li[0]/options</xpath>


As far as I can tell, the li # starts at 1. So, your other patch would be
<Patch> <!--- Important! Not <Defs> -->
  <Operation Class="PatchOperationAdd">
    <xpath>//FactionDef[defName = "Tribe"]/pawnGroupMakers/li[3]/options</xpath>

XeoNovaDan

This works. Thank you very much! I'm used to working with where lists start with 0 :P

SihvMan

Quote from: XeoNovaDan on May 20, 2017, 12:48:28 PM
This works. Thank you very much! I'm used to working with where lists start with 0 :P

Same. Especially confusing consider C# uses 0 start lists.

Glad I could help. Let me know when your mod is open to the public.

XeoNovaDan

The mod's already out, this is just the next update which should be up soon-ish.

I've never really programmed with C# - I've only just started programming late last year as that's when my school's started teaching GCSE Computing, and I've only programmed with Python, although that follows the same 'list start with 0' convention. C# is certainly something I hope to learn in the not-too-far future