Modding a new 'type' of nutrient dispenser

Started by scr1982, March 07, 2014, 11:43:04 PM

Previous topic - Next topic

scr1982

Hi all,

I am trying to build a mod that makes beer and I thought the nutrient dispenser item would be better to mod out than a table item. So I tried using similar XML to make this. However when the 'BeerDispenser' is built it operates just like a normal dispenser. I can't find anywhere to make beer come out rather than Nutrient Paste. There is no recipe def for Nutrient paste but there is a (unused?) thingdef for MealNutrientPaste. Any ideas of how to adapt to make this work?

Nutrient Dispenser Def adapted for beer brewing.
<ThingDef ParentName="BuildingBase">
<defName>BeerDispenser</defName>
<eType>BuildingComplex</eType>
<label>Brewery</label>
<thingClass>Building_NutrientPasteDispenser</thingClass>
<texturePath>Things/Building/NutrientDispenser</texturePath>
<altitudeLayer>BuildingTall</altitudeLayer>
<passability>Impassable</passability>
<castEdgeShadows>true</castEdgeShadows>
<fillPercent>1</fillPercent>
<maxHealth>350</maxHealth>
<flammability>1.0</flammability>
<description>Brews Beer for the needy.</description>
<comps>
<li>
<compClass>CompPowerTrader</compClass>
<startElectricalFires>true</startElectricalFires>
<basePowerConsumption>200</basePowerConsumption>
</li>
</comps>
<size>(3,4)</size>
<workToBuild>600</workToBuild>
<costList>
<li>
<thingDef>Metal</thingDef>
<count>90</count>
</li>
</costList>
<overdraw>true</overdraw>
<interactionSquareOffset>(0,0,3)</interactionSquareOffset>
<hasInteractionSquare>true</hasInteractionSquare>
<killedLeavings>
<li>
<thingDef>DebrisSlag</thingDef>
<count>6</count>
</li>
</killedLeavings>
<filthLeavings>
<li>
<thingDef>SlagRubble</thingDef>
<count>3</count>
</li>
</filthLeavings>
<leaveResourcesWhenKilled>true</leaveResourcesWhenKilled>
<surfaceNeeded>Heavy</surfaceNeeded>
<designationCategory>Building</designationCategory>
<staticSunShadowHeight>0.75</staticSunShadowHeight>
</ThingDef>


Example meal produced:
<ThingDef ParentName="MealBase">
<defName>Beer</defName>
<label>Beer</label>
<description>Brewed beer for the stressed or depressed person.</description>
<texturePath>Things/Resource/Beer/Beer</texturePath>
<basePrice>2.5</basePrice>
<food>
<quality>Meal</quality>
<nutrition>22</nutrition>
<eatenDirectThought>DrankBeerThought</eatenDirectThought> <!-- new thought type -->
<eatEffect>DrankBeer</eatEffect> <!-- Use new Eat Effect -->
<ticksBeforeSpoil>80000</ticksBeforeSpoil>
</food>
</ThingDef>


Example Beer Recipe:
<RecipeDef>
<defName>BrewBeer</defName>
<label>Brewing beer</label>
<description>Basic beer.</description>
<jobString>Brewing Beer.</jobString>
<workAmount>300</workAmount>
<workTimeSkillNeed>CookTime</workTimeSkillNeed>
<ingredients>
<li>
<filter>
<thingDefs>
<li>Grain</li>
</thingDefs>
</filter>
<count>10</count>
</li>
</ingredients>
<products>
<li>
<thingDef>Beer</thingDef>
<count>1</count>
</li>
</products>
<parentIngredientFilter>
<thingDefs>
<li>Grain</li>
</thingDefs>
</parentIngredientFilter>
<defaultIngredientFilter>
<thingDefs>
<li>Grain</li>
</thingDefs>
</defaultIngredientFilter>
<skillRequirements>
<li>
<skill>Cooking</skill>
<minLevel>1</minLevel>
<!-- <minLevel>5</minLevel>  leveling cooking still not implemented -->
</li>
</skillRequirements>
</RecipeDef>


To me, it looks like "      <thingClass>Building_NutrientPasteDispenser</thingClass>" is the culprit and what I am trying to do can't occur with the current level of modding. Will someone verify this?

As an alternative, I can always make a normal thingdef in the furniture way, but I wanted to try and use dispenser/hoppers for this.

Thanks for help.

Nasikabatrachus

I could be wrong, but I think Psyckosama tried to do something similar with the NPD for this mod and it didn't work out. The important parts of Building_NutrientPasteDispenser seem baked into the game code for now.

You'll have to make a worktable. Just be advised: worktables have to be 3 by 1 to be recognized as worktables by the workgiver AI. I spent a few hours trying to figure out why the worktable I partially modeled on the NPD wasn't doing anything.

scr1982

Quote from: Nasikabatrachus on March 08, 2014, 01:31:21 AM
worktables have to be 3 by 1 to be recognized as worktables by the workgiver AI. I spent a few hours trying to figure out why the worktable I partially modeled on the NPD wasn't doing anything.

That's interesting I made a 1x1 Mill for my grain mod and it works...

Thank you for the tips on NutrientPasteDispenser code stuff - that makes sense and confirms my hunch. :)

palandus

@Nasikabatrachus; What size were you using, and were you using the table in a wide open space (so that the Standing Location wasn't blocked)

Nasikabatrachus

Quote from: palandus on March 08, 2014, 02:30:44 AM
@Nasikabatrachus; What size were you using, and were you using the table in a wide open space (so that the Standing Location wasn't blocked)

I was using a 3 by 4 tile size work table, and whenever I tested it, it was out in the open. Eventually I set the interaction square to 0,0,-1 and tested various sizes and found that, of the sizes I tested, only 3,4 would work. I'd love to know if I missed something.