Recipe Events
PlanetsLib includes one event that recipes can hook into using RecipePrototype::PlanetsLib_recipe_effects. This event adds items to the machine's ingredient inventory on craft. Additional events may be added in the future.
RecipePrototype field: PlanetsLib_recipe_effects [table]
returned_ingredients[table(ItemProduct)]- When this field is defined, returned items are inserted into the crafting machine's input. The field must be defined before data-final-fixes. PlanetsLib sets
raise_on_craftedon the recipe and adds a tooltip describing the return. - Only items are supported. Defining
type = "fluid"raises an error during data-final-fixes. - Supported fields:
name(ItemID) — The item to return. It should match an ingredient of the recipe so PlanetsLib can track its production statistics.type— Must be"item".amount(number) — The number of items returned per craft, or per batch when usingbatch_count.independent_probability(number, 0–1) — Rolls separately for this returned ingredient on every craft.shared_probability({min, max}, 0–1) — Uses the craft's shared roll. The ingredient is returned when the roll is betweenminandmax, inclusive.mindefaults to0andmaxto1.ignored_by_productivity(number) — On a productivity-bonus craft, PlanetsLib returnsamount - ignored_by_productivityinstead ofamount. This returns the base amount on a normal craft without duplicating the ignored part on bonus crafts.batch_count(positive number) — On a normal craft, instead of returningamountevery craft, PlanetsLib insertsamount * batch_countitems with probability1 / batch_count. This reduces the frequency of insertions without changing the expected return rate. (Earlier documentation called this fieldbatch_size; the implementation usesbatch_count.)
- If neither probability field is set, the ingredient is returned on every craft.
- PlanetsLib derives the internal fields
add_to_stats,amount_minus_ignored_by_productivity,inverse_batch_count, andno_probabilityduring data-final-fixes. Do not set these yourself. - When the returned item matches a recipe ingredient, PlanetsLib sets that ingredient's
ignored_by_statsto its full amount. Do not rely on a customignored_by_statsvalue for that ingredient.
- When this field is defined, returned items are inserted into the crafting machine's input. The field must be defined before data-final-fixes. PlanetsLib sets
Known limitations
- The tooltip displays
shared_probabilityas a percentage ((max - min) * 100), butindependent_probabilityas the raw 0–1 value. This is a cosmetic inconsistency. - When batching skips an insertion, the skipped return is not reflected in the machine's production statistics. Returned items are also not subtracted from consumption statistics.
- The derived
add_to_statsvalue is currently unused by the runtime handler.
Example
ingredients = {
{type="item", name="cellulose", amount=15},
{type="item", name="alumina-crushed", amount=1},
},
results = {
{type="fluid", name="petroleum-gas", amount=20},
{type="fluid", name="tar", amount=8},
},
PlanetsLib_recipe_effects = {
returned_ingredients = {
{type="item", name="alumina-crushed", amount=1,shared_probability = {min=0,max=0.9},ignored_by_productivity=1},
},
},
