How to make a new worktable?

Started by Vilusia, October 05, 2014, 10:23:42 PM

Previous topic - Next topic

Vilusia

Is there a tutorial on how to make a new worktable in RimWorld? I used to be able to do it... but that was 6 months ago. Before when i did it I had to replace the butchery table with my new table. That was because the only way my new table would work was if I had the same def name as the butchery table.
  <ThingDef ParentName="BuildingBase">
    <DefName>BoneShrine</DefName>
    <EType>Building_WorkTable</EType>
    <label>bone shrine</label>
    <ThingClass>Building_WorkTable</ThingClass>
    <Description>Deliever those who dare go against the will of the Bone gods and you shall receive BONES! </Description>
    <graphicPathSingle>Things/Building/Production/TableButcher</graphicPathSingle>
    <CostList>
      <Metal>60</Metal>
    </CostList>
    <constructEffect>ConstructWood</constructEffect>
    <AltitudeLayer>Waist</AltitudeLayer>
    <UseStandardHealth>True</UseStandardHealth>
    <statBases>
      <WorkToBuild>1000</WorkToBuild>
      <MaxHealth>180</MaxHealth>
      <Flammability>1.0</Flammability>
    </statBases>
    <Size>(3,1)</Size>
    <Overdraw>False</Overdraw>
    <DesignationCategory>Production</DesignationCategory>
    <Passability>Impassable</Passability>
    <hasInteractionSquare>True</hasInteractionSquare>
    <interactionSquareOffset>(0,0,-1)</interactionSquareOffset>
    <itemSurface>True</itemSurface>
    <recipes>
      <li>BoneTake</li>
    </recipes>
    <inspectorTabs>
      <li>ITab_Bills</li>
    </inspectorTabs>
    <building>
      <spawnedConceptLearnOpportunity>BillsTab</spawnedConceptLearnOpportunity>
    </building>
  </ThingDef>


This is my code before I set it to the same def name as Butcher table. Am I doing something wrong?

Check out Bone Mod! Updates almost daily.


Vilusia

I honestly have no clue how to get this to work. Is there a full tutorial on this from start to finish? Without documentation this is very hard.

Check out Bone Mod! Updates almost daily.

Rikiki

There was one tutorial here but it is outdatted. :(

I learned the different needed elements (recipe, workgiver, workbench, resource) by looking at a simple mod like glassworks.
Just adapt the new XML parameters structure from the core and it should work.

The best way however is to grab a working mod and play with it by modifying 1 parameter at a time and look at its effect in-game.
The forum is well active and you should get an answer if you ask with enough details/screenshots/output_log. ;)

mrofa

It did get kinda more complicated..., from one side i was impressed by the additional stuff and on the other side i wanted to send death threats to tynan X_X
Did get to it eventually so here how it looks.
So you will need to make folders and xmls in them like:
RecipeDefs
StatDefs(new SkillNeedDefs)
ThingDefs
WorkGiverDefs

Wont write you whats do what since im to pretty much lost in all this, but it works.

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


<RecipeDef>
<defName>MakeSleepPills</defName>
<label>Make Sleeping Pills</label>
<description>Haplo Labs patent 109-41920-2877761 Code Name: Sleeping Pills</description>
<jobString>Cooking.</jobString>
<workAmount>500</workAmount>
<workSpeedStat>MedCookTime</workSpeedStat>
<efficiencyStat>MedCookEfficiency</efficiencyStat>
<workEffect>ButcherMechanoid</workEffect>
        <sustainerSoundDef>Recipe_ButcherCorpseMechanoid</sustainerSoundDef>
    <ingredients>
<li>
<filter>
<thingDefs>
<li>Squirrel_Corpse</li>
</thingDefs>
</filter>
<count>1</count>
</li>
<li>
<filter>
<thingDefs>
<li>Silver</li>
</thingDefs>
</filter>
<count>5</count>
</li>
</ingredients>
<products>
<SleepPills>1</SleepPills>
</products>
<fixedIngredientFilter>
<thingDefs>
<li>Squirrel_Corpse</li>
<li>Silver</li>
</thingDefs>
</fixedIngredientFilter>
<skillRequirements>
<li>
<skill>Medicine</skill>
<minLevel>6</minLevel>
</li>
</skillRequirements>
<skillGains>
<li>
<skill>Medicine</skill>
<xp>500</xp>
</li>
</skillGains>
</RecipeDef>

</RecipeDefs>





StatDefs.xml

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

  <StatDef>
    <defName>MedCookTime</defName>
    <label>Meds mixing speed</label>
<description>Speed at witch person press max speed button on the mixer.</description>
    <category>PawnWork</category>
    <defaultBaseValue>1</defaultBaseValue>
    <toStringStyle>PercentZero</toStringStyle>
    <statFactors>
      <li>WorkSpeedGlobal</li>
    </statFactors>
    <skillNeedFactors>
      <li Class="SkillNeed_BaseBonus">
<skill>Cooking</skill>
<baseFactor>2.25</baseFactor>
<bonusFactor>0.05</bonusFactor>
      </li>
    </skillNeedFactors>
    <activityFactors>
      <li>
        <activity>Consciousness</activity>
        <weight>1</weight>
      </li>
      <li>
        <activity>Sight</activity>
        <weight>0.2</weight>
      </li>
      <li>
        <activity>Manipulation</activity>
        <weight>0.9</weight>
      </li>
    </activityFactors>
  </StatDef>
 
    <StatDef>
    <defName>MedCookEfficiency</defName>
    <label>Mixing processing efficiency</label>
    <description>Ability up to how much pawn can cout before dropping all materials in mixer.</description>
    <category>PawnWork</category>
    <defaultBaseValue>1</defaultBaseValue>
    <toStringStyle>PercentZero</toStringStyle>
    <statFactors>
      <li>WorkSpeedGlobal</li>
    </statFactors>
    <skillNeedFactors>
      <li Class="SkillNeed_BaseBonus">
<skill>Cooking</skill>
<baseFactor>0.7</baseFactor>
<bonusFactor>0.065</bonusFactor>
      </li>
    </skillNeedFactors>
    <activityFactors>
      <li>
        <activity>Consciousness</activity>
        <weight>1</weight>
      </li>
      <li>
        <activity>Sight</activity>
        <weight>0.5</weight>
      </li>
      <li>
        <activity>Manipulation</activity>
        <weight>0.9</weight>
      </li>
    </activityFactors>
  </StatDef>
 
</SkillNeeds>


ThingDef.xml

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

<ThingDef>
<defName>SleepPills</defName>
<eType>Item</eType>
<label>Sleeping Pills</label>
<thingClass>ThingWithComponents</thingClass>
<category>Item</category>
<graphicPathSingle>Clutter/Various/SeepingPills</graphicPathSingle>
<altitudeLayer>Waist</altitudeLayer>
<useStandardHealth>true</useStandardHealth>
<shaderType>Transparent</shaderType>
<statBases>
<MaxHealth>150</MaxHealth>
<Flammability>1.0</Flammability>
</statBases>
<stackLimit>75</stackLimit>
<alwaysHaulable>true</alwaysHaulable>
<storeCategories>
      <li>Manufactured</li>
</storeCategories>
<tickerType>Normal</tickerType>
<tradersCarry>false</tradersCarry>
<destroyOnDrop>false</destroyOnDrop>
    <menuHidden>false</menuHidden>
<comps>
<li>
<compClass>CompForbiddable</compClass>
</li>
</comps>
<selectable>true</selectable>
<description>Sleeping pills, miracle of modern science and almost safe to use</description>
</ThingDef>


</ThingDefinitions>


WorkGiverDefs.xml

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

<WorkGiverDef>
<defName>DoBillsCookMed</defName>
<giverClass>WorkGiver_DoBill</giverClass>
<workType>Cooking</workType>
<priorityInType>95</priorityInType>
<billGiverDef>ClutterMedicMixerA</billGiverDef>
<verb>mix</verb>
<gerund>mixing</gerund>
<requiredActivities>
<li>Manipulation</li>
</requiredActivities>
</WorkGiverDef>

</WorkGivers>
All i do is clutter all around.

Rikiki

QuoteSpeed at witch person press max speed button on the mixer.
Ability up to how much pawn can cout before dropping all materials in mixer.

I love those easter eggs ;D

Vilusia

Here I'm just going to post my codes because I think Im missing something so painfully obvious like I always do.

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

<RecipeDef>
<defName>BoneTake</defName>
<label>Gather bones</label>
<description>Take the body of those who defile the bone gods and turn them into something useful.</description>
<jobString>Making bones.</jobString>
<workAmount>450</workAmount>
<workEffect>ButcherFlesh</workEffect>
<workSpeedStat>ButcheryFleshSpeed</workSpeedStat>
<efficiencyStat>ButcheryFleshEfficiency</efficiencyStat>
    <sustainerSoundDef>Recipe_ButcherCorpseFlesh</sustainerSoundDef>
    <ingredients>
<li>
<filter>
<categories>
<li>Corpses</li>
</categories>
</filter>
<count>1</count>
</li>
</ingredients>
<products>
      <Bone>206</Bone>
</products>
<fixedIngredientFilter>
<categories>
<li>Corpses</li>
</categories>
<exceptedCategories>
<li>CorpsesMechanoid</li>
</exceptedCategories>
      <specialFiltersToDisallow>
        <li>AllowRotten</li>
      </specialFiltersToDisallow>
</fixedIngredientFilter>
    <defaultIngredientFilter>
      <thingDefs>
        <li>Human_Corpse</li>
      </thingDefs>
      <specialFiltersToAllow>
        <li>AllowCorpsesColonist</li>
        <li>AllowCorpsesStranger</li>
      </specialFiltersToAllow>
    </defaultIngredientFilter>
</RecipeDef>
 
</RecipeDefs>


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

  <WorkGiverDef>
    <defName>DoBillsMakeBones</defName>
    <giverClass>WorkGiver_DoBill</giverClass>
    <workType>Cooking</workType>
    <priorityInType>10</priorityInType>
    <workTableDef>BoneShrine</workTableDef>
    <verb>produce bone</verb>
    <gerund>producing bone</gerund>
  </WorkGiverDef>

</WorkGivers>


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



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


  <ThingDef ParentName="BuildingBase">
    <DefName>BoneShrine</DefName>
    <EType>Building_WorkTable</EType>
    <label>boneshrine</label>
    <ThingClass>Building_WorkTable</ThingClass>
    <Description>Deliver those who dare go against the will of the Bone gods and you shall receive BONES! </Description>
    <graphicPathSingle>Things/Building/Production/TableButcher</graphicPathSingle>
    <CostList>
      <Metal>60</Metal>
    </CostList>
    <constructEffect>ConstructWood</constructEffect>
    <AltitudeLayer>Waist</AltitudeLayer>
    <UseStandardHealth>True</UseStandardHealth>
    <statBases>
      <WorkToBuild>1000</WorkToBuild>
      <MaxHealth>180</MaxHealth>
      <Flammability>1.0</Flammability>
    </statBases>
    <Size>(3,1)</Size>
    <Overdraw>False</Overdraw>
    <DesignationCategory>Production</DesignationCategory>
    <Passability>Impassable</Passability>
    <hasInteractionSquare>True</hasInteractionSquare>
    <interactionSquareOffset>(0,0,-1)</interactionSquareOffset>
    <itemSurface>True</itemSurface>
    <recipes>
      <li>BoneTake</li>
    </recipes>
    <inspectorTabs>
      <li>ITab_Bills</li>
    </inspectorTabs>
    <building>
      <spawnedConceptLearnOpportunity>BillsTab</spawnedConceptLearnOpportunity>
    </building>
  </ThingDef>

</ThingDefs>


If one of you guys see something wrong it would help me a bunch. I tried everything you both said and I still cant see what Im doing wrong ;-; I bet it's something stupid :/

Check out Bone Mod! Updates almost daily.

Rikiki

I cannot test it right now, so could please give us more details about what does not work ?
Do you see your building ?
Can you build it ?
Is it about the bill not handled by colonists ?

Is one of your colonist able to cook (and is it enabled in the overview tab) ?

Appart from that, I need to test with the game.
Could you also post your output_log.txt file ?

mrofa

All i do is clutter all around.

Haplo

I think he uses vanilla stats so that he doesn't need to make his own for it:

<workSpeedStat>ButcheryFleshSpeed</workSpeedStat>
<efficiencyStat>ButcheryFleshEfficiency</efficiencyStat>


skullywag

also just as an aside, start  a new game if youve been tweaking code and reloading a saved game, sometimes it kicks things into gear, I think removing and readding the bill can also have this effect, but worth doing it from scratch tbh.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Vilusia

The colonists ignore the bill that I put on there. I can build it, and make the recipe.

Check out Bone Mod! Updates almost daily.

skullywag

your work giver is all wrong. you need billgiverdef in there, where did you get worktabledef from?

your first workgiver above that last one is right...
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Rikiki

#13
Yep, just tested it and it works.
You need to replace workTableDef by billGiverDef.

Check the console next time (press ² or ~ key next to 1/&), it was written in it.

Vilusia

Quote from: Rikiki on October 07, 2014, 11:38:40 AM
Yep, just tested it and it works.
You need to replace workTableDef by billGiverDef.

Check the console next time (press � or ~ key next to 1/&), it was written in it.
Weird I checked the console and had no bugs.

Check out Bone Mod! Updates almost daily.