Can someone help me stop the red errors with my simple mod:

Started by dearmad, August 17, 2020, 04:25:45 PM

Previous topic - Next topic

dearmad

It's just a simple texture replacement with an added fire overlay....

Here's the mod:
https://steamcommunity.com/sharedfiles/filedetails/?id=2200414144&tscn=1597678509

Here's the only code it executes:

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

<Patch>
<Operation Class="PatchOperationReplace">
    <xpath>/Defs/ThingDef[defName = "MeditationSpot"]/graphicData/texPath</xpath>
<value>
<texPath>Spots/Candle</texPath>
</value>
  </Operation>



<Operation Class="PatchOperationAdd">
    <xpath>Defs/ThingDef[defName="MeditationSpot"]</xpath>
<value>
<comps>
<li Class="CompProperties_FireOverlay">
<fireSize>0.25</fireSize>
<offset>(0,0,0.16)</offset>
</li>
<li Class="CompProperties_Glower">
<glowRadius>1</glowRadius>
<glowColor>(255,153,50,0)</glowColor>
</li>
</comps>
</value>

    </Operation>
 
  </Patch>
 


Here's the red error I can replicate users are getting, but I'm not sure WHY this would happen:

XML error: Duplicate XML node name comps in this XML block: <ThingDef ParentName="BuildingBase"><defName>MeditationSpot</defName><label>meditation spot</label><description>Designates a spot for meditation. Psycasters can meditate here to gain psyfocus. If a focus object like a sculpture is nearby, the psycaster will be able to focus on it to boost their psyfocus gain. However, different people are able to use different focus objects.</description><graphicData><texPath>Spots/Candle</texPath><graphicClass>Graphic_Single</graphicClass></graphicData><altitudeLayer>FloorEmplacement</altitudeLayer><statBases><WorkToBuild>0</WorkToBuild></statBases><rotatable>false</rotatable><scatterableOnMapGen>false</scatterableOnMapGen><useHitPoints>False</useHitPoints><designationCategory>Misc</designationCategory><passability>Standable</passability><drawGUIOverlay>true</drawGUIOverlay><building><sowTag>SupportPlantsOnly</sowTag><canPlaceOverImpassablePlant>false</canPlaceOverImpassablePlant><ai_chillDestination>false</ai_chillDestination><artificialForMeditationPurposes>false</artificialForMeditationPurposes></building><comps><li Class="CompProperties_UsesMeditationFocus" /><li Class="CompProperties_AssignableToPawn"><drawUnownedAssignmentOverlay>false</drawUnownedAssignmentOverlay><compClass>CompAssignableToPawn_MeditationSpot</compClass></li></comps><placeWorkers><li>PlaceWorker_MeditationSpot</li></placeWorkers><designationHotKey>Misc12</designationHotKey><comps><li Class="CompProperties_FireOverlay"><fireSize>0.25</fireSize><offset>(0,0,0.16)</offset></li><li Class="CompProperties_Glower"><glowRadius>1</glowRadius><glowColor>(255,153,50,0)</glowColor></li></comps></ThingDef>
Verse.Log:Error(String, Boolean)
Verse.XmlInheritance:CheckForDuplicateNodes(XmlNode, XmlNode)
Verse.XmlInheritance:ResolveXmlNodeFor(XmlInheritanceNode)
Verse.XmlInheritance:ResolveXmlNodesRecursively(XmlInheritanceNode)
Verse.XmlInheritance:ResolveXmlNodesRecursively(XmlInheritanceNode)
Verse.XmlInheritance:ResolveXmlNodes()
Verse.XmlInheritance:Resolve()
Verse.LoadedModManager:ParseAndProcessXML(XmlDocument, Dictionary`2)
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.<>c:<Start>b__6_1()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.<>c:<UpdateCurrentAsynchronousEvent>b__27_0()
System.Threading.ThreadHelper:ThreadStart_Context(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object)
System.Threading.ThreadHelper:ThreadStart()


and

Exception while executing PostLoad on null: System.NullReferenceException: Object reference not set to an instance of an object
  at Verse.DirectXmlToObject.TryDoPostLoad (System.Object obj) [0x0000a] in <a5cb16e7582e46cc8acabb9853272707>:0
Verse.Log:Error(String, Boolean)
Verse.DirectXmlToObject:TryDoPostLoad(Object)
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
Verse.DirectXmlToObject:ListFromXml(XmlNode)
Verse.DirectXmlToObject:ListFromXmlReflection(XmlNode)
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
Verse.DirectXmlToObject:ObjectFromXmlReflection(XmlNode, Boolean)
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
Verse.DirectXmlToObject:ListFromXml(XmlNode)
Verse.DirectXmlToObject:ListFromXmlReflection(XmlNode)
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
Verse.DirectXmlToObject:ObjectFromXmlReflection(XmlNode, Boolean)
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
Verse.DirectXmlToObject:ListFromXml(XmlNode)
Verse.DirectXmlToObject:ListFromXmlReflection(XmlNode)
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
Verse.DirectXmlToObject:ObjectFromXmlReflection(XmlNode, Boolean)
Verse.DirectXmlToObject:ObjectFromXml(XmlNode, Boolean)
Verse.DirectXmlToObject:ObjectFromXmlReflection(XmlNode, Boolean)
Verse.DirectXmlLoader:DefFromNode(XmlNode, LoadableXmlAsset)
Verse.LoadedModManager:ParseAndProcessXML(XmlDocument, Dictionary`2)
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.<>c:<Start>b__6_1()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.<>c:<UpdateCurrentAsynchronousEvent>b__27_0()
System.Threading.ThreadHelper:ThreadStart_Context(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object)
System.Threading.ThreadHelper:ThreadStart()



The mod FUNCTIONS perfectly in game... so IDK.

Shinzy

I believe the meditation spot already has a <comps> in it and you're adding another one, it complains about that

Try to extend the xpath for the add operation to <xpath>Defs/ThingDef[defName="MeditationSpot"]/comps</xpath>
and then add the value inside of that

dearmad

If I add the value inside of that- would it look like:

<Operation Class="PatchOperationAdd">
        <xpath>Defs/ThingDef[defName="MeditationSpot"]/comps</xpath>
        <value>
            <li Class="CompProperties_FireOverlay">
                <fireSize>0.25</fireSize>
                <offset>(0,0,0.16)</offset>
            </li>
            <li Class="CompProperties_Glower">
                <glowRadius>1</glowRadius>
                <glowColor>(255,153,50,0)</glowColor>
            </li>
        </value>
   
    </Operation>



dearmad


dearmad

I actually found the issue. My mod is OK, it's just that Vanilla Furniture Expanded does something wonky with mediation and my patch method or his don't cooperate.