Excepting ingredients in recipes

Started by Litcube, October 24, 2016, 03:57:26 PM

Previous topic - Next topic

Litcube

How do I disallow insect meat in my recipedef?

Dingo

Hey there Litcube, glad you're making mods! You can find all possible RecipeDefs for A15c here.

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.

Litcube

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. 

kaptain_kavern


Litcube


Dingo

Try <exceptedThingDefs>Megaspider_Meat</exceptedThingDefs> as implied by this post and Races_Animal_Insect.xml.

Litcube

BAM!  You got it!  That worked!

BAM!

Edit: BAM!

Fluffy (l2032)

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.)

gariba

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?

nccvoyager

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..)

gariba

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.

kaptain_kavern

#11
I haven't the right code in mind, right now, but search for the mod "animal hide working" 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

gariba

I had forgotten completely about that mod. Anyway, it's just as Dingo Fluffy pointed out. Thanks!