Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.
This repository was archived by the owner on Jun 25, 2020. It is now read-only.

Mod doesn't check if "parts" field is already added.  #4

@rheirman

Description

@rheirman

Apparently the mod doesn't check properly whether other mods already add the "parts" field when you're adding in statparts, resulting in errors like:

XML RimWorld.StatDef defines the same field twice: parts.
I suggest fixing this by adding in some extra checks in your xpaths. What I generally do is this:

<Operation Class="PatchOperationSequence">
	<success>Always</success>
	<operations>
		<li Class = "PatchOperationAdd">
			<xpath>Defs/StatDef[defName="[defName here]"]/parts</xpath>
			<value>
				<li Class="[class here]"/>
			</value>
		</li>
	</operations>
</Operation>
<Operation Class="PatchOperationSequence">
	<success>Always</success>
	<operations>
		<li Class = "PatchOperationAdd">
			<xpath>Defs/StatDef[defName="[defName here]" and not (parts)]</xpath>
			<value>
				<parts>
					<li Class="[class here]"/>
				</parts>
			</value>
		</li>
	</operations>
</Operation>

It's not very elegant, since you need two patches now, but it does prevent errors when other mods also add in parts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions