Getting a NullReferenceException when trying to create products.

Started by EzraN, August 06, 2016, 05:50:11 PM

Previous topic - Next topic

EzraN

I am trying to figure out how to use the xml modding system, but I am having some trouble. Currently I am trying to create a workbench that will combine two ingredients to form a new item, but right now I have it just convert slag into steel. The whole system works until the slag is supposed to turn into steel where the debug menu says
JobDriver threw exception in initAction, Pawn=Emmie, Job=DoBill A=Thing_RobotTable53782, Exception: System.NullREferenceException: Object reference not set to an instance of an object

The problem does not happen when I remove the products item in the recipe def I assume since it doesn't try to create the object. Is there a thing I am missing when I spawn it? Right now I pulled parts of the core mod xml code to try to get it to work is there things that I am missing/have things not needed?

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

  <ThingDef Name="BenchBase" ParentName="BuildingBase" Abstract="True">
    <castEdgeShadows>true</castEdgeShadows>
    <staticSunShadowHeight>0.20</staticSunShadowHeight>
  </ThingDef>

  <ThingDef ParentName="BenchBase">
    <DefName>RobotTable</DefName>
    <label>Robot construction table</label>
    <ThingClass>Building_WorkTable</ThingClass>
    <Description>A workbench equipped for building advanced robots.</Description>
    <graphicData>
      <texPath>Things/Building/Production/TableSculpting</texPath>
      <graphicClass>Graphic_Multi</graphicClass>
      <drawSize>(3.5,1.5)</drawSize>
      <damageData>
        <cornerTL>Damage/Corner</cornerTL>
        <cornerTR>Damage/Corner</cornerTR>
        <cornerBL>Damage/Corner</cornerBL>
        <cornerBR>Damage/Corner</cornerBR>
      </damageData>
    </graphicData>
   
    <CostList>
      <Steel>50</Steel>
    </CostList>
    <stuffCategories>
      <li>Metallic</li>
      <li>Woody</li>
    </stuffCategories>
    <costStuffCount>75</costStuffCount>
   
    <AltitudeLayer>Building</AltitudeLayer>
    <fillPercent>0.5</fillPercent>
    <useHitPoints>True</useHitPoints>
    <statBases>
      <WorkToMake>2500</WorkToMake>
      <MaxHitPoints>180</MaxHitPoints>
      <Flammability>1.0</Flammability>
      <Cleanliness>0</Cleanliness>
    </statBases>
    <Size>(3,1)</Size>
    <DesignationCategory>Production</DesignationCategory>
    <Passability>PassThroughOnly</Passability>
    <pathCost>70</pathCost>
    <hasInteractionCell>True</hasInteractionCell>
    <interactionCellOffset>(0,0,-1)</interactionCellOffset>
    <surfaceType>Item</surfaceType>
    <inspectorTabs>
      <li>ITab_Bills</li>
    </inspectorTabs>
    <building>
      <spawnedConceptLearnOpportunity>BillsTab</spawnedConceptLearnOpportunity>
    </building>
    <comps>
      <li Class="CompProperties_AffectedByFacilities">
        <linkableFacilities>
          <li>ToolCabinet</li>
        </linkableFacilities>
      </li>
    </comps>
   
    <recipes>
      <li>craftWire</li>
    </recipes>

  </ThingDef>
</Buildings>


RecipeDef:

<?xml version="1.0" encoding="utf-8" ?>
<RecipeDefs>
  <RecipeDef>
    <defName>craftWire</defName>
    <label>Craft electrical wires</label>
    <description>Creates wires useful for building robots.</description>
    <jobString>Crafting Wire.</jobString>
    <workAmount>500</workAmount>


    <fixedIngredientFilter>
      <thingDefs>
        <li>ChunkSlagSteel</li>
      </thingDefs>
    </fixedIngredientFilter>

    <products>
      <li>
        <Steel>1</Steel>
      </li>
    </products>
   
  </RecipeDef>
</RecipeDefs>


WorkGiverDef:
<?xml version="1.0" encoding="utf-8" ?>
<WorkGivers>
  <WorkGiverDef>
    <defName>DoBillsRobotTable</defName>
    <label>Work at robotics table</label>
    <giverClass>WorkGiver_DoBill</giverClass>
    <workType>Smithing</workType>
    <fixedBillGiverDefs>
      <li>RobotTable</li>
    </fixedBillGiverDefs>
    <verb>work</verb>
    <gerund>working at</gerund>
  </WorkGiverDef>
</WorkGivers>


I'm kinda new to xml code but have a bit of a background in html.

kaptain_kavern

#1
You can also look in "RimWorld1249Win_Data\output_log.txt"

Usually error that i catch from the output_log gave me more informations/clues about what was wrong.

I just eyeball through your code and haven't seen anything completely wrong. Did you use a new world each time when testing? (i tend to have those kind of error when i have a old bill on a bench and modifying the recipe associated).


Once the modlist is set i use the -quicktest launching option to have a new world for each test :p

My shortcut to launch the game looks like this : "RimWorld1249Win.exe -quicktest -savedatafolder=SaveData"

EzraN

That shortcut will help a lot thanks, it looks like the output is pretty much the same as the debug log message except for the unity debug bindings at the end with line 37.


JobDriver threw exception in initAction. Pawn=Anamù, Job=DoBill A=Thing_RobotTable55596, Exception: System.NullReferenceException: Object reference not set to an instance of an object
  at Verse.GenRecipe+<MakeRecipeProducts>c__Iterator1D7.MoveNext () [0x00000] in <filename unknown>:0
  at System.Collections.Generic.List`1[Verse.Thing].AddEnumerable (IEnumerable`1 enumerable) [0x00000] in <filename unknown>:0
  at System.Collections.Generic.List`1[Verse.Thing]..ctor (IEnumerable`1 collection) [0x00000] in <filename unknown>:0
  at System.Linq.Enumerable.ToList[Thing] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
  at Verse.AI.Toils_Recipe+<FinishRecipeAndStartStoringProduct>c__AnonStorey34A.<>m__4FA () [0x00000] in <filename unknown>:0
  at Verse.AI.JobDriver.TryActuallyStartNextToil () [0x00000] in <filename unknown>:0

(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)

EzraN

I did some more looking around and went through the core mods folder, copied the slag smelting recipe def and replaced the broken recipe and then slowly began to filter through all of the parts changing it to fit what I am trying to do and it seems to work. I think there might have been a small misspelling or a combination of pieces not placed correctly that would break the system.