Deterministic Recycler


Adds a new Recycler that takes in more ingredients to get rid of random chance. While keeping ratios. Inserter stack size 4 is recommended.

Tweaks
a month ago
2.0 - 2.1
583
Manufacturing

b I cannot recycle armor

Is this a limitation of the mod, or is it a bug? Is there any way to make the armor recyclable?

I added this code to the do_deterministic_recycling(recipe) function in prototypes -> recycling, and it seems to work.
if recipe.ingredients and recipe.ingredients[1] then
local item = get_prototype("item", recipe.ingredients[1].name)
if item and item.stack_size == 1 then
return false
end
end

a month ago

I had a lot of problems with armor items during development. As when they have a module grid they become unstackable, by the engine without telling you. For those armors I have implemented a framing recipe. Do you play with an armor mod which does not work? For me it looks like it works as intended. Keep in mind you need at least 4 items for it to deterministically recycle. Do you perhaps have the replace vanilla recipe setting on? I don't see how disregarding items with a stacksize of 1 helps with them recycling. Happy to help more with a deeper explanation of the problem.

I’m using a custom mod that only changes the armor inventory size, so I don't think that's the issue. In your mod's settings, 'include self recycling recipes' is unchecked and 'replace recycling recipes' is checked—does that affect it in any way? Also, when I mentioned I couldn't recycle the armor, I was using the vanilla recycler instead of the one provided by the mod, so I didn't even get to test if selecting the armor recipe would have worked.

a month ago

Thanks for the reply.You found a combination, I indeed did not account for. The issue should be fixed and now work as intended. Read further for an expanation why.

'Replace recycling recipes' overrides the base recycling recipes so the deterministic recipes work in the default recycler. There is a difference between items with stack_size = 1 and items that have the unstackable flag. Items with stack_size 1 can still be stacked if the recipe calls for it. Items that are flagged unstackable can never be stacked. for example armors with equipment grids. Although they have the flag not set directly. they have it implied by the engine. By the recycler constraint of giving back 25% of the recipe cost, this mod needs at least 4 items to be deterministic. As a design choice I don't care if the item is already deterministic. it needs at least 4 items to recycle in this system. Also the ingredient list of recipes can't have duplicates. So the item can't stack and I can't have 4 times the same item to recycle it. Therefore I had to create a dummy item with no functionally other than being stackable. So in the base game mostly the armor items. I call it framing. It just adds another step to make unstackble items stackable for recycling. As it turns out I forgot to add the framing recipes to the base recycler.

New response