How to use 2 textures depending of the materials in wich the furnitures is built

Started by MrRoux, December 13, 2015, 05:45:26 PM

Previous topic - Next topic

MrRoux

Hello all,

I tried to find some answer on google and on the Rimworld modding currently published topics but i obviously failed to find what i am looking for. I looked at some mod, etc, looked at the Core code and as said in the title,

i can't find a way to make the game use a different textures for the furniture (a table for a single person if you wonder) depending on the ressources used to built it. It is supposed to work as for the table short and the table long for exemple :/.

Anyone hanging around here with a clue/ answer/ solution? :)

Some stuff to help you help me:

<---------------------------- what i did and why ------------------------------>
Since in the core they do this for the textures:
<texPath>Things/Building/Furniture/TableShort</texPath>
with the name of the textures being:
TableShortSteel_back.psd
TableShortWood_back.psd

i did this for mine:
<texPath>Things/Building/Furniture/TablePersonal</texPath>
with the name of the texture being:
TablePersonalSteel_back.png
TablePersonalWood_back.png
<----------------------------End what i did and why ------------------------------>

<---------------------------- Code for the furniture -------------------------------->
<ThingDef>
  <ThingDef Name="BuildingBase" Abstract="True">
    <category>Building</category>
    <soundImpactDefault>BulletImpactMetal</soundImpactDefault>
    <selectable>true</selectable>
    <drawerType>MapMeshAndRealTime</drawerType>
    <terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
    <repairEffect>Repair</repairEffect>
    <leaveResourcesWhenKilled>true</leaveResourcesWhenKilled>
    <filthLeaving>BuildingRubble</filthLeaving>
  </ThingDef>
 
<!-- Table base -->
  <ThingDef Abstract="True" ParentName="BuildingBase" Name="TableBaseSpe">
    <thingClass>Building</thingClass>
    <altitudeLayer>Waist</altitudeLayer>
    <description>People eat off tables when chairs are placed facing them.</description>
    <passability>PassThroughOnly</passability>
    <castEdgeShadows>true</castEdgeShadows>
    <pathCost>60</pathCost>
    <fillPercent>0.4</fillPercent>
    <minifiedDef>MinifiedFurniture</minifiedDef>
    <socialPropernessMatters>true</socialPropernessMatters>
    <stuffCategories>
      <li>Metallic</li>
      <li>Woody</li>
      <li>Stony</li>
    </stuffCategories>
    <leaveResourcesWhenKilled>true</leaveResourcesWhenKilled>
    <designationCategory>Furniture</designationCategory>
    <staticSunShadowHeight>0.20</staticSunShadowHeight>
    <surfaceType>Eat</surfaceType>
    <comps>
      <li>
        <compClass>CompGatherSpot</compClass>
      </li>
      <li>
        <compClass>CompQuality</compClass>
      </li>
    </comps>
  </ThingDef>
 
  <ThingDef ParentName="TableBaseSpe">
    <defName>TablePersonal</defName>
    <label>table (Personal)</label>
    <graphicData>
      <texPath>Things/Building/Furniture/TablePersonal</texPath>
      <graphicClass>Graphic_Single</graphicClass>
      <drawSize>(1,1)</drawSize>
    </graphicData>
    <statBases>
      <MaxHitPoints>75</MaxHitPoints>
      <WorkToMake>300</WorkToMake>
      <Flammability>1.0</Flammability>
      <Beauty>8</Beauty>
    </statBases>
    <size>(1,1)</size>
    <costStuffCount>10</costStuffCount>
    <rotatable>false</rotatable>
  </ThingDef>
 
</ThingDef>
<-------------------------- end code for the furniture ------------------------------>

Thanks you for your help :)

Fluffy (l2032)

Are you sure the core tables actually have different textures for wood and steel? I can find no mention of that in the core files.

As for colouring by stuff, that's just a colour overlay, and in most cases doesn't require much changing. If you want to colour only parts of the texture, you need to set a mask texture, see for example the bed.

MrRoux

Yep their is one texture per type of ressource you can make the furniture of.

Actually, it is handle in both a logical and weird way XD.
I tried to just put one kind of textures like this:
<texPath>Things/Building/Furniture/TablePersonalWood_back</texPath>
And it all works perfectly, it give the possibility to change the kind of ressources you want the furniture to be made with and adapt directly the texture to the one with Wood or Steel in the name.

I find it weird because it detect the others (steel and silver) from the name you give him which already contain the ressource used. So it means that they are parsing the name of the png file you give to take only the name ("TablePersonnal") part and add the material needed (Wood or Steel or else) to give the texture corresponding to the furniture you want. I find it absolutely insane XD. It would be simpler to just ask for the name, and detect the texture with the extensions.
But, maybe it avoid any finding problems if you have two textures with those name:
- firsttexture
- firstexturebutdifferent
So that maybe it cannot find "firsttexturebutdifferent" when it is looking for the texture. But even then, their is way to prevent it like just concatenate the name with the ressource you want with the side you want. So i wonder why, why did they do that? why was it simpler? :/