Mysterious XML Error

Started by Ekarus, July 22, 2017, 08:12:38 AM

Previous topic - Next topic

Ekarus

I'm at a loss at this point. The game dislikes several lines of XML in two definitions. However the catch is I copy/pasted the second definition, and five more, off the first. But after the second one it has no problems. Copy/Pasting from the definitions it likes results in new errors, commenting out the sections it dislikes results in no errors, editing one of the later definitions with the ones it dislikes results in errors.

I have no earthly idea what I'm doing wrong. Below are the two things it dislikes, followed by a third it likes.

<RecipeDef Abstract="True" Name="EPRecipeAnchientProsthetics">
<workSpeedStat>SmithingSpeed</workSpeedStat>
<soundWorking>Recipe_Machining</soundWorking>
<unfinishedThingDef>EPUnfinishedProsthetic</unfinishedThingDef>
<workSkill>Crafting</workSkill>
<workAmount>200</workAmount>
<jobString>Crafting prosthesis.</jobString>
<skillRequirements>
<li>
<skill>Crafting</skill>
<minLevel>0</minLevel>
</li>
</skillRequirements>
          <recipeMaker>
<researchPrerequisite>EPAnchientProsthetics</researchPrerequisite>
        <recipeUsers>
        <li>CraftingSpot</li>
      </recipeUsers>
    </recipeMaker>
</RecipeDef>

<RecipeDef Abstract="True" Name="EPRecipeMedievalProsthetics">
<workSpeedStat>SmithingSpeed</workSpeedStat>
<soundWorking>Recipe_Machining</soundWorking>
<unfinishedThingDef>EPUnfinishedProsthetic</unfinishedThingDef>
<workSkill>Crafting</workSkill>
<workAmount>300</workAmount>
<jobString>Crafting prosthesis.</jobString>
<skillRequirements>
<li>
<skill>Crafting</skill>
<minLevel>4</minLevel>
</li>
</skillRequirements>
    <recipeMaker>
<researchPrerequisite>EP20thCenturyProsthetics</researchPrerequisite>
      <recipeUsers>
        <li>TableMachining</li>
      </recipeUsers>
    </recipeMaker>
</RecipeDef>

<RecipeDef Abstract="True" Name="EPRecipe20thCenturyProsthetics">
<workSpeedStat>SmithingSpeed</workSpeedStat>
<soundWorking>Recipe_Machining</soundWorking>
<unfinishedThingDef>EPUnfinishedProsthetic</unfinishedThingDef>
<workSkill>Crafting</workSkill>
<workAmount>500</workAmount>
<jobString>Crafting prosthesis.</jobString>
<skillRequirements>
<li>
<skill>Crafting</skill>
<minLevel>5</minLevel>
</li>
</skillRequirements>
    <recipeMaker>
<researchPrerequisite>EP20thCenturyProsthetics</researchPrerequisite>
      <recipeUsers>
        <li>TableMachining</li>
      </recipeUsers>
    </recipeMaker>
</RecipeDef>


Here's the first of the two error messages from the game, maybe one of you can make sense of it.
RimWorld 0.17.1557 rev1153
Verse.Log:Message(String)
RimWorld.VersionControl:LogVersionNumber()
Verse.Root:CheckGlobalInit()
Verse.Root:Start()
Verse.Root_Entry:Start()

XML error: <recipeMaker><researchPrerequisite>EP20thCenturyProsthetics</researchPrerequisite><recipeUsers><li>TableMachining</li></recipeUsers></recipeMaker> doesn't correspond to any field in type RecipeDef.
Verse.Log:Error(String)
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.<AllDefsFromAsset>c__Iterator226:MoveNext()
Verse.ModContentPack:LoadDefs(IEnumerable`1)
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__84E()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__84C()

XML error: <recipeMaker><researchPrerequisite>EPAnchientProsthetics</researchPrerequisite><recipeUsers><li>CraftingSpot</li></recipeUsers></recipeMaker> doesn't correspond to any field in type RecipeDef.
Verse.Log:Error(String)
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
Verse.<AllDefsFromAsset>c__Iterator226:MoveNext()
Verse.ModContentPack:LoadDefs(IEnumerable`1)
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__84E()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__84C()


Edit: Just realized I posted this to the wrong board, my bad.

jamaicancastle

I think the core of the problem is that those lines are enclosed in a <recipeMaker> tag. The recipe maker is a property of an item, specifically a crafted item, that defines the recipe to make it; it's not a property of a recipe itself. If you remove that tag and the corresponding closing tag, the researchPrerequisite and recipeUsers tags should work on their own.

As for why it stops throwing errors after the second, I couldn't tell you. Maybe it just stops recording them?

kaptain_kavern

Yep. I can only agree with JamaicanCastle, there is no <recipeMaker> tags in RecipeDefs

Ekarus

That'd explain a lot... So if I put the bench it's made at in the item definition it should work fine then? Or do I need to put the research requirement there too?

AngleWyrm

Something like this:
  • RecipeDef
    • ingredients
    • products
    • recipeUsers
    • researchPrerequisite (optional)
My 5-point rating system: Yay, Kay, Meh, Erm, Bleh

jamaicancastle

Quote from: Ekarus on July 22, 2017, 05:44:40 PM
That'd explain a lot... So if I put the bench it's made at in the item definition it should work fine then? Or do I need to put the research requirement there too?
You have two approaches: either you put all of the vital information in a <recipeMaker> tag in the thingDef (you can check the apparel or weapon items to see how this works), OR you can do as you are doing, and write an explicit recipeDef. Don't do both or you'll confuse it and end up with two recipes!

Both researchPrerequisite and recipeUsers work as tags directly inside the recipeDef. All you need to do is remove the lines <recipeMaker> and </recipeMaker>.

Ekarus

A great many thanks to everyone who helped.

I've got a lot of work to do now... XD But, the problem has been solved.