Ludeon Forums

RimWorld => Mods => Help => Topic started by: Vilusia on October 05, 2014, 10:23:42 PM

Title: How to make a new worktable?
Post by: Vilusia on October 05, 2014, 10:23:42 PM
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?
Title: Re: How to make a new worktable?
Post by: Rikiki on October 06, 2014, 03:19:15 AM
Look at this: http://ludeon.com/forums/index.php?topic=5857.msg62545#msg62545 (http://ludeon.com/forums/index.php?topic=5857.msg62545#msg62545)

Same problem I think. ;)
Title: Re: How to make a new worktable?
Post by: Vilusia on October 06, 2014, 03:54:55 AM
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.
Title: Re: How to make a new worktable?
Post by: Rikiki on October 06, 2014, 04:54:23 AM
There was one tutorial here (http://rimworldwiki.com/Modding_Tutorials/Smelter) 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. ;)
Title: Re: How to make a new worktable?
Post by: mrofa on October 06, 2014, 10:41:20 AM
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>
Title: Re: How to make a new worktable?
Post by: Rikiki on October 06, 2014, 10:51:42 AM
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
Title: Re: How to make a new worktable?
Post by: Vilusia on October 06, 2014, 06:02:55 PM
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 :/
Title: Re: How to make a new worktable?
Post by: Rikiki on October 07, 2014, 02:58:58 AM
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 ?
Title: Re: How to make a new worktable?
Post by: mrofa on October 07, 2014, 03:22:13 AM
You might be missing stat defs
Title: Re: How to make a new worktable?
Post by: Haplo on October 07, 2014, 06:15:24 AM
I think he uses vanilla stats so that he doesn't need to make his own for it:

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

Title: Re: How to make a new worktable?
Post by: skullywag on October 07, 2014, 10:23:17 AM
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.
Title: Re: How to make a new worktable?
Post by: Vilusia on October 07, 2014, 11:25:50 AM
The colonists ignore the bill that I put on there. I can build it, and make the recipe.
Title: Re: How to make a new worktable?
Post by: skullywag on October 07, 2014, 11:35:44 AM
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...
Title: Re: How to make a new worktable?
Post by: 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.
Title: Re: How to make a new worktable?
Post by: Vilusia on October 07, 2014, 11:56:15 AM
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.
Title: Re: How to make a new worktable?
Post by: Vilusia on October 07, 2014, 02:42:49 PM
Ah I see now. I needed to start a new colony. Thanks all, sorry for being so oblivious x.x
Everything is working now!
Title: Re: How to make a new worktable?
Post by: skullywag on October 07, 2014, 02:46:25 PM
Yeah start doing that out of habit now when modding itll save your brain lots of "WTF!" moments. :)
Title: Re: How to make a new worktable?
Post by: mrofa on October 07, 2014, 02:46:36 PM
Um you shouldnt need to.
If you still got your old colony, try to build new workbench there, since the ones already build had saved recipes and stuff
Title: Re: How to make a new worktable?
Post by: skullywag on October 07, 2014, 02:49:37 PM
as I said it might be the bill, remove the bill and redo it. I just found for sanity sake restarting is simpler.
Title: Re: How to make a new worktable?
Post by: Vilusia on October 07, 2014, 03:01:56 PM
It's all fixed now :) I did need to start a new colony. Idk why but that fixed it :)