Ludeon Forums

RimWorld => Mods => Help => Topic started by: Litcube on October 24, 2016, 03:57:26 PM

Title: Excepting ingredients in recipes
Post by: Litcube on October 24, 2016, 03:57:26 PM
How do I disallow insect meat in my recipedef?
Title: Re: Excepting ingredients in recipes
Post by: Dingo on October 24, 2016, 04:17:48 PM
Hey there Litcube, glad you're making mods! You can find all possible RecipeDefs for A15c here (https://github.com/RimWorldMod/RimworldModdingFiles/blob/master/Defs/RecipeDefs/Recipes.xml).

Have a look at <fixedIngredientFilter>. It can contain <exceptedCategories> and/or <exceptedThingDefs>.

Optionally, if you would like the user to have control over it have a look at <defaultIngredientFilter>, which is an optional def list.
Title: Re: Excepting ingredients in recipes
Post by: Litcube on October 24, 2016, 06:34:44 PM
Hey!  That's pretty handy stuff right there!  Definitely going to be useful.

However, I suppose I still don't know which thingdef to use for insect meat. 
Title: Re: Excepting ingredients in recipes
Post by: kaptain_kavern on October 24, 2016, 06:39:36 PM
InsectMeat
Title: Re: Excepting ingredients in recipes
Post by: Litcube on October 25, 2016, 10:13:58 AM
Quote from: kaptain_kavern on October 24, 2016, 06:39:36 PM
InsectMeat

Apparently, that is not the case.  InsectMeat isn't recognized.
Title: Re: Excepting ingredients in recipes
Post by: Dingo on October 25, 2016, 10:21:57 AM
Try <exceptedThingDefs>Megaspider_Meat</exceptedThingDefs> as implied by this post (https://ludeon.com/forums/index.php?topic=27060.msg273708#msg273708) and Races_Animal_Insect.xml.
Title: Re: Excepting ingredients in recipes
Post by: Litcube on October 25, 2016, 10:28:16 AM
BAM!  You got it!  That worked!

BAM!

Edit: BAM!
Title: Re: Excepting ingredients in recipes
Post by: Fluffy (l2032) on October 26, 2016, 08:14:51 AM
Just for the record, meat and leather are both implied thingdefs, meaning that they are generated from pawnkinddefs at runtime - you won't find them in the def xmls. IIRC, both are generated with a name matching the pattern <PawnKindDef.Label>_<meat/leather>. Hopefully that helps a bit with future endeavors.

(also, if you want your mod to play nice with other mods adding more animals you should consider using categories, and/or using a .dll to dynamically inject (dis)allowed defs at runtime based on the pawnkinds that are available.)
Title: Re: Excepting ingredients in recipes
Post by: gariba on October 26, 2016, 11:23:09 AM
Quote from: Fluffy (l2032) on October 26, 2016, 08:14:51 AM
Just for the record, meat and leather are both implied thingdefs, meaning that they are generated from pawnkinddefs at runtime - you won't find them in the def xmls. IIRC, both are generated with a name matching the pattern <PawnKindDef.Label>_<meat/leather>. Hopefully that helps a bit with future endeavors.

(also, if you want your mod to play nice with other mods adding more animals you should consider using categories, and/or using a .dll to dynamically inject (dis)allowed defs at runtime based on the pawnkinds that are available.)

Does that mean that, if I want to use leather for a recipe, but exempt Rat Leather from it, I should include <li>Rat_Leather</li> on the excepted list? Likewise, does that syntax allow me to define a recipe that uses specifically Rat leather?
Title: Re: Excepting ingredients in recipes
Post by: nccvoyager on October 26, 2016, 12:01:43 PM
Adding a fixed ingredient filter will force a specific ingredient to be used in a recipe.
Of course, this also means that only that ingredient can be used in the amount specified.
I would suggest the joywire surgery recipe as an example.
(The filter can also be used in conjunction with excepted ingredients and a filter to force an amount of one ingredient, and allow any combination of the others to complete the recipe.
EX: Recipe requries 40 leather. You must have and use 20 rat leather, but you can finish the recipe with 10 turkey leather and 10 human leather, or 20 human leather, etc..)
Title: Re: Excepting ingredients in recipes
Post by: gariba on October 26, 2016, 12:30:35 PM
Sorry, my post was kind of misleading. My problem was actually the syntax used to refer to specific leathers, since it's an implied thingdef. I tried defining thrumbofur as an ingredient to a recipe once and it didn't work because of that.
Title: Re: Excepting ingredients in recipes
Post by: kaptain_kavern on October 26, 2016, 01:53:08 PM
I haven't the right code in mind, right now, but search for the mod "animal hide working" (https://ludeon.com/forums/index.php?topic=2569.0) it has building that only take one type of leather for building and looking at it's code, I recall there were exactly the same kind of recipe you are searching for
Title: Re: Excepting ingredients in recipes
Post by: gariba on October 26, 2016, 07:22:00 PM
I had forgotten completely about that mod. Anyway, it's just as Dingo Fluffy pointed out. Thanks!