[Solved]A few xml modding questions

Started by BaconBits, August 10, 2016, 02:07:41 PM

Previous topic - Next topic

BaconBits

Hi everyone, I'm currently making a BBQ Mod (https://ludeon.com/forums/index.php?topic=23228.0) wich I believe I'm about 80% finished with code and textures. However, I'm running into Def's Ive never messed with. Through research and refering to other mods, I have been able to figure out most of everything i need, though I do have a few questions. Right now I feel I might be over thinking this to the point of missing the easy answers.

1. I want to be able to make BBQ food (like Ribs, Sausage, Potatoes, etc.) be used as ingredients
    when making BBQ Meals as well as be meals themselves. Do I need to have each said food item in two seperate ThingCategoryDefs or can I use one Def and have two parent names? Or Is what I want to do impossible?

2. I want to be able to assign pawns to use the Butcher Table to make raw Sausages. Do I need to do WorkGiverDefs to Prepare raw food at the butcher table, or, can I just assign it to the butcher table in the recipe?

I thought I had another question, but, I'm sure I'll remember it later.

Thanks in advance for any help you can provide!

CannibarRechter

Start reading through the various RecipeDefs. Recipes_Food.xml would be a good place to take a peek. Here's one I just made up. This says the recipe is for 1 of either A or B, AND 1 of C. You can also replace the thingDefs stanza with categories. I should imagine you can also create your own categories, but I haven't tried that.

      <ingredients>
         <li>
            <filter>
               <thingDefs>
                  <li>A</li>
                  <li>B</li>
               </thingDefs>
            </filter>
            <count>1</count>
         </li>
         <li>
            <filter>
               <thingDefs>
                  <li>C</li>
               </thingDefs>
            </filter>
            <count>1/count>
         </li>
      </ingredients>
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

BaconBits

Quote from: CannibarRechter on August 10, 2016, 02:57:01 PM
Start reading through the various RecipeDefs. Recipes_Food.xml would be a good place to take a peek. Here's one I just made up. This says the recipe is for 1 of either A or B, AND 1 of C. You can also replace the thingDefs stanza with categories. I should imagine you can also create your own categories, but I haven't tried that.

      <ingredients>
         <li>
            <filter>
               <thingDefs>
                  <li>A</li>
                  <li>B</li>
               </thingDefs>
            </filter>
            <count>1</count>
         </li>
         <li>
            <filter>
               <thingDefs>
                  <li>C</li>
               </thingDefs>
            </filter>
            <count>1/count>
         </li>
      </ingredients>


LOL....now see, that's what i meant when I said "I might be over thinking this to the point of missing the easy answers". Then again, it was 3am and I had been staring at code for 3+ hrs. I did that for the BBQ Sauce. I'll give that a shot and see what happens when I'm at the testing phase.

Any thoughts on the second question?

CannibarRechter

With regards to question 2, I don't know if I'm doing it right, but I've made several new recipes and set their work location to existing assets in the game quite successfully by merely using the recipeUsers stanza in the RecipeDef:

    <recipeUsers>
      <li>HandTailoringBench</li>
      <li>ElectricTailoringBench</li>    
    </recipeUsers>

Once that is defined the Bill appears at the workstation, and the pawns will execute the Bill.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

BaconBits

Quote from: CannibarRechter on August 10, 2016, 03:18:59 PM
With regards to question 2, I don't know if I'm doing it right, but I've made several new recipes and set their work location to existing assets in the game quite successfully by merely using the recipeUsers stanza in the RecipeDef:

    <recipeUsers>
      <li>HandTailoringBench</li>
      <li>ElectricTailoringBench</li>    
    </recipeUsers>

Once that is defined the Bill appears at the workstation, and the pawns will execute the Bill.

Yep, That's the way I have it set. I really hate second guessing myself. Thank you for taking the time to help out.

CannibarRechter

There is another way. You can do it without recipes at all (I think). Consider the case of ThingDefs_Misc/Weapons_Guns.xml, Gun_AssaultRifle.

This item has:

    <costList>
      <Steel>100</Steel>
      <Component>4</Component>
    </costList>

It inherits from "BaseMakeableGun", which has this stanza:

    <recipeMaker>
      <workSpeedStat>SmithingSpeed</workSpeedStat>
      <workSkill>Crafting</workSkill>
      <effectWorking>Smith</effectWorking>
      <soundWorking>Recipe_Smith</soundWorking>
      <recipeUsers>
        <li>TableMachining</li>
      </recipeUsers>
      <unfinishedThingDef>UnfinishedGun</unfinishedThingDef>
    </recipeMaker>

So it appears you can put the recipes on the items directly, although in this case, I don't see a way to do the whole either/or/and thing I described previously.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

BaconBits

HA...I remember the 3rd question. When making new items like the BBQ Meals and food, Am I right in assuming that I need to write a new ThingCategoryDef like this:

<ThingCategoryDef>
        <defName>BBQMeals</defName>
        <label>meals</label>
        <parent>Foods</parent>
        <resourceReadoutRoot>true</resourceReadoutRoot>
        <iconPath>Ui/Icons/ThingCategories/FoodMeals</iconPath>
    </ThingCategoryDef>

<ThingCategoryDef>
      <defName>BBQMeats</defName>
      <label>foods</label>
      <parent>Resources</parent>
</ThingCategoryDef>

<ThingCategoryDef>
      <defName>BBQVegitables</defName>
      <label>foods</label>
      <parent>Resources</parent>
</ThingCategoryDef>

CannibarRechter

#7
I haven't tried that. But I think you can do this, mark your goods with the category, and then use the categories tag in the Recipe instead of the thingDefs tag. Certainly, I would say that this is how the rest of the Core appears to be managed.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

BaconBits

Here is an example of how I have a recipe set up (i have not changed the ingredients yet)
<RecipeDef Name="BBQMealsBase" Abstract="True">
<jobString>Barbecuing.</jobString>
<workSpeedStat>CookSpeed</workSpeedStat>
<effectWorking>Cook</effectWorking>
<soundWorking>Recipe_CookMeal</soundWorking>
<allowMixingIngredients>true</allowMixingIngredients>
<ingredientValueGetterClass>IngredientValueGetter_Nutrition</ingredientValueGetterClass>
<workSkill>Cooking</workSkill>
<recipeUsers>
<li>FueledBBQGrill</li>
<li>ElectricBBQGrill</li>
<li>ElectricStove</li>
<li>FueledStove</li>
</recipeUsers>
</RecipeDef>

 
<RecipeDef Name="CookSimpleBBQMeal" ParentName="BBQMealsBase">
<defName>CookSimpleBBQMeal</defName>
<label>cook simple bbq meal</label>
<description>Cooks simple meals with barbecued meat and raw plant ingredients.</description>
<ingredients>
<li>
<filter>
<categories>
<li>FoodRaw</li>
</categories>
</filter>
<count>2.0</count>
</li>
<li>
<filter>
<categories>
<li>BBQSauce</li>
</categories>
</filter>
<count>0.5</count>
</li>
</ingredients>
<products>
<SimpleBBQMeal>4</SimpleBBQMeal>
</products>
<fixedIngredientFilter>
<categories>
<li>FoodRaw</li>
</categories>
<disallowedSpecialFilters>
<li>AllowPlantFood</li>
</disallowedSpecialFilters>
</fixedIngredientFilter>
<defaultIngredientFilter>
<categories>
<li>FoodRaw</li>
</categories>
<exceptedCategories>
<li>EggsFertilized</li>
</exceptedCategories>
<exceptedThingDefs>
<li>Human_Meat</li>
</exceptedThingDefs>
</defaultIngredientFilter>
<skillRequirements>
<li>
<skill>Cooking</skill>
<minLevel>4</minLevel>
</li>
</skillRequirements>
</RecipeDef>

CannibarRechter

So, cook simple BBQ meal produces 4 SimpleBBQMeal, takes 2 Raw food and .5 BBQ Sauce, filters to FoodRaw and (I guess I don't understand the disallowedSpecialFilter), but does not appear to include BBQ sauce? That last part is confusing. I think you might want to add the BBQSauce categories in there.

Also, do you have several types of BBQSauce? That would be the only motivation for having it as a category, imo.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

BaconBits

Quote from: CannibarRechter on August 10, 2016, 03:42:26 PM
So, cook simple BBQ meal produces 4 SimpleBBQMeal, takes 2 Raw food and .5 BBQ Sauce, filters to FoodRaw and (I guess I don't understand the disallowedSpecialFilter), but does not appear to include BBQ sauce? That last part is confusing. I think you might want to add the BBQSauce categories in there.

Also, do you have several types of BBQSauce? That would be the only motivation for having it as a category, imo.

This was made last night so I havn't made changes. I only have one BBQ Sauce atm. The DisallowedSpecialFilter I believe makes it so that type of items are not allowed in creating the meals. I could very well be wrong.

kaptain_kavern

#11
It's not something i'll dare calling guide or even explanations : but here I wrote a piece of text trying to explain how recipes work (for surgery) but that should remain similar : https://github.com/kaptain-kavern/ADogSaid/issues/11

Also if I understand what your trying to achieve : yes you got thinks right with the categories. I mean using Vanilla default "Food" category ensure compatibility with other mods.

Looks like your on the right tracks and CannibalRechter explain things way better than I could have done :-)





Also i started to try to put in place some modding helps here : https://github.com/RimWorldMod/RimworldModdingFiles/wiki
But hey sorry it's just a mess atm ;)

Ho I even got a dummy file for recipes : https://github.com/RimWorldMod/RimworldModdingFiles/blob/master/Defs/RecipeDefs/Recipes_Empty.xml

BaconBits

Quote from: kaptain_kavern on August 10, 2016, 04:33:48 PM
It's not something i'll dare calling guide or even explanations : but here I wrote a piece of text trying to explain how recipes work (for surgery) but that should remain similar : https://github.com/kaptain-kavern/ADogSaid/issues/11

Also if I understand what your trying to achieve : yes you got thinks right with the categories. I mean using Vanilla default "Food" category ensure compatibility with other mods.

Looks like your on the right tracks and CannibalRechter explain things way better than I could have done :-)





Also i started to try to put in place some modding helps here : https://github.com/RimWorldMod/RimworldModdingFiles/wiki
But hey sorry it's just a mess atm ;)

Ho I even got a dummy file for recipes : https://github.com/RimWorldMod/RimworldModdingFiles/blob/master/Defs/RecipeDefs/Recipes_Empty.xml
I forgot that I had saved the [A14] XML Auto-Documentation to my browser favs. I'll check out the ADogSaid link, And the recipe link seems to be just as you said, " a dummy file". But, it's a good resource.

After taking another look at the code I had questions about, it's starting to make sense, a little.
I geuss the only thing to really do is test it (I'm far from that right now).


kaptain_kavern