I thought I only needed a quality filter for recipe ingredients/results for what I want, but this is also required for what I'd like.
+1
A setting on recipes to only output 1 item.
- BraveCaperCat
- Filter Inserter
- Posts: 442
- Joined: Mon Jan 15, 2024 10:10 pm
- Contact:
Re: A setting on recipes to only output 1 item.
Creator of multiple mods, including Quality Assurance - My most popular one.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Add Support for Mutually Exclusive "Loot Table" Style Probabilistic Outputs in Recipes
Add a new optional functionality to recipe definitions for handling probabilistic outputs as a weighted "loot table" system, where a single roll determines the outcome, ensuring mutually exclusive results (i.e., exactly one outcome is selected, no overlaps or misses). This would complement the current independent-roll system and be particularly useful for modders creating low-volume or high-value item production recipes.
Current Implementation
In the existing system, probabilistic outputs in recipes (e.g., "chance to craft X") are rolled independently for each possible item. For example:
In Uranium Processing: 99.3% chance for U-238 and 0.7% chance for U-235.
The game performs separate rolls:
Do you get U-238? (Yes/No based on probability)
Do you get U-235? (Yes/No based on probability)
This can result in getting both items, neither, or one—similar to scrap recycling or other random recipes.
While this works fine for high-volume production in vanilla Factorio (where only a few recipes use randomness, and statistical averages smooth out variances), it breaks down in modded scenarios with "low-scale" production involving expensive or rare items. For instance:
If modding two variants of a Spidertron with 50% chance each, independent rolls lead to:
25% chance of getting neither (wasted resources).
25% chance of getting both (unintended duplication).
Only 50% chance of getting exactly one.
Proposed Feature: "weighted_results" for Recipes
Introduce a new recipe parameter that allows defining outcomes with weights, performing a single roll across a total weight pool. Outcomes would be mutually exclusive—one and only one is guaranteed per craft.
For example instead of using
Code: Select all
results = {
{type="item", name="uranium-235", probability=0.007, amount=1},
{type="item", name="uranium-238", probability=0.993, amount=1}
}
Code: Select all
weighted_results= {
{type="item", name="uranium-235", weight=1, amount=1},
{type="item", name="uranium-238", weight=143, amount=1}
}
• Total weight: 1 + 143 = 144.
• Single roll: Generate a random number from 1 to 144.
• If 1: Output U-235 (approximates ~0.7% chance).
• If 2-144: Output U-238 (approximates ~99.3% chance).
• Always outputs exactly one item—no "both" or "neither."
Alternatively, add a flag to toggle weighted behavior with "false" as default
This is similar to how Quality levels are already handled in the game, but Quality asume that alternative result is always "better" and require whole quality system/setup and AFAIK there is no hadcrafting quality or quality chance increase for separate recepie.
Additional options for flexibility:
Allow including a "nothing" outcome with weight (e.g., for true failure chances): {item=nil, weight=10}.
Support multiple rolls per outcome if needed (e.g., bundles).
Benefits
Enables modders to create balanced random rewards without statistical pitfalls in small-batch crafting.
Improves realism for loot-like mechanics (e.g., randomized enemy drops, treasure chests, or variant items like Spidertrons).
Re: Add Support for Mutually Exclusive "Loot Table" Style Probabilistic Outputs in Recipes
Merged with existing request.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.