Total noob trying to mod for the first time

Started by Torres, April 21, 2017, 05:33:28 AM

Previous topic - Next topic

Torres

I wanted to try and create a mod that allows the player to research better tool cabinets then unlock them and build them, but I can't get it to work.

I'd really appreciate some help since this is my first time modding. Thanks in advance

ResearchProjectDefs XML


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

<ResearchProjectDef>
<defName>Research_Improved_Tools</defName>
<label>Improved Tool Cabinet</label>
<description>Better tools for your pawns</description>
<baseCost>800</baseCost>
<techLevel>Industrial</techLevel>
<prerequisites>
<li>Electricity</li>
</prerequisites>
<researchViewX>10</researchViewX>
<researchViewY>0</researchViewY>

</ResearchProjectDef>

<ResearchProjectDef>
<defName>Research_Advanced_Tools</defName>
<label>Advanced Tool Cabinet</label>
<description>Even better tools to help your pawns work faster, bit more expensive though and requires power.</description>
<baseCost>1500</baseCost>
<techLevel>Industrial</techLevel>
<prerequisites>
<li>Electricity</li>
<li>ElectricSmelting</li>
</prerequisites>
<researchViewX>11</researchViewX>
<researchViewY>0</researchViewY>
</ResearchProjectDef>

<ResearchProjectDef>
<defName>Research_Glitterworld_Tools</defName>
<label>Glitterworld Tool Cabinet</label>
<description>Glitterworld tech helping your pawns work more efficiently,requires quite some power .</description>
<baseCost>5000</baseCost>
<techLevel>Spacer</techLevel>
<prerequisites>
<li>Electricity</li>
<li>ElectricSmelting
<li>MultiAnalyzer</li>
</prerequisites>
<researchViewX>11</researchViewX>
<researchViewY>0</researchViewY>
</ResearchProjectDef>

</ResearchProjectDefs>




ThingDefs_Buildings XML


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

<Buildings>
   <ThingDef ParentName="BuildingBase">
    <defName>ImprovedToolCabinet</defName>
    <label>Improved Tool Cabinet</label>
    <graphicData>
  <texPath>Textures/Things/Buildings/Improved</texPath>
      <graphicClass>Graphic_Multi</graphicClass>
      <drawSize>(2,1)</drawSize>
      <color>(96,114,95)</color>
      <category>Building</category>
<thingClass>Building</thingClass>
  <damageData>
        <cornerTL>Damage/Corner</cornerTL>
        <cornerTR>Damage/Corner</cornerTR>
        <cornerBL>Damage/Corner</cornerBL>
        <cornerBR>Damage/Corner</cornerBR>
      </damageData>
    </graphicData>
    <altitudeLayer>Building</altitudeLayer>
    <passability>PassThroughOnly</passability>
    <castEdgeShadows>true</castEdgeShadows>
    <staticSunShadowHeight>0.35</staticSunShadowHeight>
    <fillPercent>0.5</fillPercent>
    <statBases>
      <MaxHitPoints>100</MaxHitPoints>
      <WorkToBuild>2200</WorkToBuild>
      <Mass>60</Mass>
      <Flammability>1.0</Flammability>
    </statBases>
    <description>Better version of the tool cabinet, increases work speed further. Needs to be placed near a workbench. One workbench can be simultaneously linked to only two tools cabinets.</description>
    <size>(2,1)</size>
    <costList>
      <Steel>200</Steel>
  <Plasteel>100</Plasteel>
  <Component>2</Component>
    </costList>
    <designationCategory>Misc</designationCategory>
    <minifiedDef>MinifiedFurniture</minifiedDef>
    <comps>
      <li Class="CompProperties_Facility">
        <statOffsets>
          <WorkTableWorkSpeedFactor>0.09</WorkTableWorkSpeedFactor>
        </statOffsets>
        <maxSimultaneous>2</maxSimultaneous>
      </li>
    </comps>
    <designationHotkey>Misc6</designationHotkey>
<placeWorkers>
<li>PlaceWorker_ShowFacilitiesConnections</li>
</placeWorkers>
<researchPrerequisites>
<li>Research_Improved_Tools</li>
</researchPrerequisites>

  </ThingDef>
 
   <ThingDef ParentName="BuildingBase">
    <defName>ToolCabinet</defName>
    <label>Advanced Tool Cabinet</label>
    <graphicData>
      <texPath>Textures/Things/Buildings/Advanced</texPath>
      <graphicClass>Graphic_Multi</graphicClass>
      <drawSize>(2,1)</drawSize>
      <color>(178,163,62)</color>
      <damageData>
        <cornerTL>Damage/Corner</cornerTL>
        <cornerTR>Damage/Corner</cornerTR>
        <cornerBL>Damage/Corner</cornerBL>
        <cornerBR>Damage/Corner</cornerBR>
      </damageData>
    </graphicData>
    <altitudeLayer>Building</altitudeLayer>
    <passability>PassThroughOnly</passability>
    <castEdgeShadows>true</castEdgeShadows>
    <staticSunShadowHeight>0.35</staticSunShadowHeight>
    <fillPercent>0.5</fillPercent>
    <statBases>
      <MaxHitPoints>150</MaxHitPoints>
      <WorkToBuild>3200</WorkToBuild>
      <Mass>260</Mass>
      <Flammability>1.0</Flammability>
    </statBases>
    <description>Better than the advanced tool cabinet, increases work speed even further but requires power. Needs to be placed near a workbench. One workbench can be simultaneously linked to only two tools cabinets.</description>
    <size>(2,1)</size>
    <costList>
      <Steel>850</Steel>
  <Plasteel>600</Plasteel>
  <Component>10</Component>
  <Uranium>50</Uranium>
    </costList>
<li Class="Properties_Power">
        <startElectricalFires>false</startElectricalFires>
        <basePowerConsumption>220</basePowerConsumption>
        <shortCircuitInRain>false</shortCircuitInRain>
      </li>
    <designationCategory>Misc</designationCategory>
    <minifiedDef>MinifiedFurniture</minifiedDef>
    <comps>
      <li Class="CompProperties_Facility">
        <statOffsets>
          <WorkTableWorkSpeedFactor>0.14</WorkTableWorkSpeedFactor>
        </statOffsets>
        <maxSimultaneous>2</maxSimultaneous>
      </li>
    </comps>
    <designationHotkey>Misc6</designationHotkey>
<placeWorkers>
<li>PlaceWorker_ShowFacilitiesConnections</li>
</placeWorkers>
<researchPrerequisites>
<li>Research_Advanced_Tools</li>
</researchPrerequisites>
  </ThingDef>



  <ThingDef ParentName="BuildingBase">
    <defName>ToolCabinet</defName>
    <label>Glitterworld Tool Cabinet</label>
    <graphicData>
      <texPath>Textures/Things/Buildings/Glitterworld</texPath>
      <graphicClass>Graphic_Multi</graphicClass>
      <drawSize>(2,1)</drawSize>
      <color>(183,75,75)</color>
      <damageData>
        <cornerTL>Damage/Corner</cornerTL>
        <cornerTR>Damage/Corner</cornerTR>
        <cornerBL>Damage/Corner</cornerBL>
        <cornerBR>Damage/Corner</cornerBR>
      </damageData>
    </graphicData>
    <altitudeLayer>Building</altitudeLayer>
    <passability>PassThroughOnly</passability>
    <castEdgeShadows>true</castEdgeShadows>
    <staticSunShadowHeight>0.35</staticSunShadowHeight>
    <fillPercent>0.5</fillPercent>
    <statBases>
      <MaxHitPoints>80</MaxHitPoints>
      <WorkToBuild>6200</WorkToBuild>
      <Mass>50</Mass>
      <Flammability>1.0</Flammability>
    </statBases>
    <description>Nanotech enhanced workstation only those that have reached Glitter knowledge can dream of it. Is quite power hungy.</description>
    <size>(2,1)</size>
    <costList>
      <Steel>1500</Steel>
  <Plasteel>2000</Plasteel>
  <Component>25</Component>
  <Uranium>150</Uranium>
    </costList>
<li Class="Properties_Power">
        <startElectricalFires>false</startElectricalFires>
        <basePowerConsumption>500</basePowerConsumption>
        <shortCircuitInRain>false</shortCircuitInRain>
     </li>
    <designationCategory>Misc</designationCategory>
    <minifiedDef>MinifiedFurniture</minifiedDef>
    <comps>
      <li Class="CompProperties_Facility">
        <statOffsets>
          <WorkTableWorkSpeedFactor>0.25</WorkTableWorkSpeedFactor>
        </statOffsets>
        <maxSimultaneous>2</maxSimultaneous>
      </li>
    </comps>
    <designationHotkey>Misc6</designationHotkey>
<placeWorkers>
<li>PlaceWorker_ShowFacilitiesConnections</li>
</placeWorkers>
<researchPrerequisites>
<li>Research_Glitterworld_Tools</li>
</researchPrerequisites>
  </ThingDef>
  </Buildings>

Shinzy

What's the problem exactly? at a glance they seem like they would/should work
(well except that you don't seem to have the Building Base abstract def anywhere, which you can find from Buildings_Base.xml)

But you still haven't specified what you need help with! :p I'm little confused

Torres

#2
You're right I should've given more details.

This is the mod's folder order.

Mod Name - Tool Cabinets Mod - NO RESEARCH
├╴About
└╴Defs--it holds ThingDefs_Buildings.xml (as posted above)
└╴Textures -- Things -- Buildings and the 3 png I'm using to tell apart each stage of development (do they have to be of a certain size? could that be the problem? hope not...)

Problem is the mod doesn't work at all when I activate it, it shows up on the list and I activate it (restart included of course) I mean there's no option to build the cabinets I modded since they're not showing in the misc menu ingame.

I'm quite unfamiliar with that "Building Base abstract ", found it but I have no idea what to do with it lol

You mean adding this to the code?
<Defs>

  <ThingDef Name="BuildingBase" Abstract="True">
    <category>Building</category>
    <thingClass>Building</thingClass>
    <soundImpactDefault>BulletImpactMetal</soundImpactDefault>
    <selectable>true</selectable>
    <drawerType>MapMeshAndRealTime</drawerType>
    <terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
    <repairEffect>Repair</repairEffect>
    <leaveResourcesWhenKilled>true</leaveResourcesWhenKilled>
    <filthLeaving>BuildingRubble</filthLeaving>
  </ThingDef>

   </Defs>


Or adding the Abstract="True" to every entry as in every tool cabinet? Thanks in advance.

minimurgle

I see the problem. In the <texpath> you have the textures folder included.
It should go like this <texpath>Things/Buildings/Improved</texpath> It's an easy mistake.

The building base is a parent. When something has the parent it inherits properties from it. So for building base all you need to do is copy and paste it at the top of your xml file. So it'd go right above your improved cabinet.
Don't mind the questions. I'm probably just confused.

Torres

Thanks for all the help I really appreciate it, if someday by chance I publish this on the workshop as I intend you (as others who lent a hand) will have honourable mentions since... I can't give out cash lol, kinda making ends meet now lolol.

So I opened the dev mode bug tracker I get this

Exception reading Tool cabinet mod.xml as XML: System.Xml.XmlException: Multiple document element was detected.  Line 20, position 2.
  at Mono.Xml2.XmlTextReader.ReadStartTag () [0x00000] in <filename unknown>:0
  at Mono.Xml2.XmlTextReader.ReadContent () [0x00000] in <filename unknown>:0
  at Mono.Xml2.XmlTextReader.ReadContent () [0x00000] in <filename unknown>:0
  at Mono.Xml2.XmlTextReader.Read () [0x00000] in <filename unknown>:0
  at System.Xml.XmlTextReader.Read () [0x00000] in <filename unknown>:0
  at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
  at System.Xml.XmlDocument.ReadNode (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
  at System.Xml.XmlDocument.Load (System.Xml.XmlReader xmlReader) [0x00000] in <filename unknown>:0
  at System.Xml.XmlDocument.LoadXml (System.String xml) [0x00000] in <filename unknown>:0
  at Verse.LoadableXmlAsset..ctor (System.String name, System.String fullFolderPath, System.String contents) [0x00000] in <filename unknown>:0
Verse.Log:Warning(String)
Verse.LoadableXmlAsset:.ctor(String, String, String)
Verse.<XmlAssetsInModFolder>c__Iterator1EB:MoveNext()
System.Collections.Generic.List`1:AddEnumerable(IEnumerable`1)
System.Collections.Generic.List`1:.ctor(IEnumerable`1)
System.Linq.Enumerable:ToList(IEnumerable`1)
Verse.ModContentPack:LoadDefs()
Verse.ModContentPack:ReloadAllContent()
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)
Verse.Root:<Start>m__735()
Verse.LongEventHandler:RunEventFromAnotherThread(Action)
Verse.LongEventHandler:<UpdateCurrentAsynchronousEvent>m__733()


Now I honestly have no idea what I was doing in the first place but this is beyond that... or me...  ???

Thanks in advance!

RawCode

QuoteLine 20, position 2.
...


please use any XML "syntax" checker to avoid issues,

Torres

Thanks, can't have 2 headers... haven't done anything remotely related to coding since college.

On the other hand I got a ton of new errors soooo I'm gonna spend some time researching and making mistakes to re-learn. :D

Thanks again!

minimurgle

I don't know what your using right now but Notepad++ is nice and I would say Sublime is amazing.
Don't mind the questions. I'm probably just confused.