Reverse Factory

by Kryzeth

Reverse Factory machine will recycle (uncraft) nearly any item placed inside. Supports the recycling of most, if not all, modded items. Fully featured integration with Bobs Mods, Industrial Revolution, and Fantario (independently, not simultaneously)

Content
14 days ago
0.13 - 2.0
66.9K
Manufacturing

g [Question/Answered] Help with compatibility

4 months ago

I have a Promethium processing mod that rebalances and enhances the promethium pack crafting chain.
So the mod makes the base game promethium produce 2 packs per craft
Then through unlocks and research I provide a recipe with different costs but crafts 10 packs, same pack, different recipe.

How can I, in my mod, detect this mod exists (this I know how to do) and ensure that when the research is done that the reverse-factory part uses the improved recipe? Do you have a document on how to plug into the api? Is there a simple call? Do you generate all the reverse-factory recipes at runtime and I am therefore SOL?

4 months ago
(updated 4 months ago)

This sounds like something that would have to be done via control.lua scripts, which I have very little knowledge or experience in, unfortunately. I can confirm that the reverse recipes are generated during the initial loading, just the vanilla recycler recipes.

I technically have a method for other mods to define custom reverse recipes, but I believe this would override the original base game recipe, which is not what you want, I think.

So you'd need to create the alternative reverse recipe on your end (call it whatever you want internally, as long as it doesn't conflict), then you would need to do some control.lua shennanigans to detect when the new research unlocks, disable the original recipe, and then enable the new recipe

Of course, I have no idea how to do these things, since I don't usually work with control.lua scripts, but there's probably something in the docs, like on_research_finished sounds like it should work as the trigger, and there's this part of the docs, should help you pull out individual recipes by name, then setting the new .enabled field, but actually putting it all together will be up to you.

I can also give you the internal name of the original reverse recipe: rf-promethium-science-pack (they're all in this format)

4 months ago

So I managed some shenanigan's and hacked a solution that didn't involve control scripts.

I also found a slight bug/issue/problem with your checkProbs function, which blocked Cryogenic science from working, even with reverse factory fluid items disabled.

Basically this is the code that works around these issues for my stream game tomorrow. I needed something working.
[code]
-- hack attempt to force the reverse factory to use the custom recipe, not the changed vanilla one.
if mods['reverse-factory'] then
local Recipe = require('kry_stdlib/stdlib/data/recipe')

-- Must be in the format of {"item type", "item name", "recipe name"}
data.raw.recipe["promethium-science-pack"].hidden = true

Recipe("cryogenic-science-pack"):remove_result("fluoroketone-hot")
Recipe("cryogenic-science-pack"):remove_ingredient("fluoroketone-cold")
Recipe("cryogenic-science-pack"):add_ingredient({type = "fluid", name = "fluoroketone-cold", amount = 3})

table.insert(rf.custom_recycle, {"tool", "promethium-science-pack", "advanced-promethium-science-pack"})

end
[/code]
I hide the base game recipe, shuffle the cryo stuff to make that work, and add my custom recipe to the list. I do this in data-updates.lua.
I have fluid returns disabled for my server, so the cold fluoroketone is just the cost of doing business and creates a nice sink.

4 months ago

If you tested it and it works, then it will work as a temporary solution for now, with a much different effect than what you'll need for the long term lol.

New response