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.

Content
22 days ago
0.13 - 2.0
67.4K
Manufacturing

g [Question/Answered] read FAQ Still unsure

a month ago
(updated a month ago)

Explaining the issue:

i have recently fixed the vanilla recycling problem my mod have had since space age releas. tho i step in to an issue with your mod and when both my mod & bobs are active my mod removes all Armour & equipment's from bobs tho when recycling my Armour MK 4 it returners the recipe from bobs MK4 rather than mine. which i hope was fixed along the recycling fix. but no so i want to ask for a bit of help to solve this on ether sides.

Have started like this on my side. Just not sure how this "rf." is required from your mod 100%. and do you have an example that i could use for the code below?

rf = {}

if mods["reverse-factory"] then
if (rf) and (rf.custom_recycle) then
table.insert(rf.custom_recycle, {"item", "example-item-result", "example-recipe"})
end
end

Again I'm no pro I still try learning easy/advanced code.

a month ago

Also came to ask if there is a way to have this auto fix itself in a way due to recipe changing in 2+ ways for vanilla & space age then many more times for any other mod compatibilities that may be loaded & re creating these senarios are tedious if one recipe results in ~50 variations.

a month ago
(updated a month ago)

So the issue is just that this "Armour MK 4" is returning the wrong ingredients?

I can tell you a bit of information on how this mod operates, that should maybe explain some things for your situation. For every item in the game, my mod checks for a recipe that has the same internal name as the item in question, which works for basically all items in the vanilla game, with the exception of recipes that are like "basic-oil-processing", or "metallic-asteroid-processing", which does not match the name for any of the items those recipes produce; these recipes don't even get looked at by my mod.

If there is no match for an item, that item gets skipped. There are some other checks the recipe has to pass before it gets a reverse recipe created (like not on blacklist, not percentage based, etc) but that's the first important milestone. If you are getting a reverse recipe that does not match the ingredients for the base recipe, then one of two things are happening: the item name does not match your intended recipe name, but another one does, so it pulls from the wrong recipe. OR your mod is loading after mine, and makes changes to the recipe that are not being accounted for. If your mod runs during data-final-fixes, then it's possible this is happening

If that info doesn't help solve the problem, then you can find examples of the manual recipe addition within my mod, under prototypes > added_manual_recipes.lua, but here's a couple of excerpts:

if mods["kj_fuel"] then
    if data.raw.item["kj_gascan"] and data.raw.recipe["kj_gascan_fill"] then
        table.insert(rf.custom_recycle, {"item", "kj_gascan", "kj_gascan_fill"})
    end
    if data.raw.item["kj_energy_cell"] and data.raw.recipe["kj_energy_cell_load"] then
        table.insert(rf.custom_recycle, {"item", "kj_energy_cell", "kj_energy_cell_load"})
    end
    if data.raw.item["kj_kerosine"] and data.raw.recipe["kj_kerosine_fill"] then
        table.insert(rf.custom_recycle, {"item", "kj_kerosine", "kj_kerosine_fill"})
    end
    if data.raw.item["kj_gasbarrel"] and data.raw.recipe["kj_gasbarrel_fill"] then
        table.insert(rf.custom_recycle, {"item", "kj_gasbarrel", "kj_gasbarrel_fill"})
    end
end

if mods["Hovercrafts"] then
    if data.raw["item-with-entity-data"]["hcraft-entity"] and data.raw.recipe["hcraft-recipe"] then
        table.insert(rf.custom_recycle, {"item-with-entity-data", "hcraft-entity", "hcraft-recipe"})
    end
    if data.raw["item-with-entity-data"]["mcraft-entity"] and data.raw.recipe["mcraft-recipe"] then
        table.insert(rf.custom_recycle, {"item-with-entity-data", "mcraft-entity", "mcraft-recipe"})
    end
    if data.raw["item-with-entity-data"]["lcraft-entity"] and data.raw.recipe["lcraft-recipe"] then
        table.insert(rf.custom_recycle, {"item-with-entity-data", "lcraft-entity", "lcraft-recipe"})
    end
end

NOTE: From my mod, I check for the existence of other mods, but other mods would want to check for the existence of mine, hence the use of

if mods["reverse-factory"] then

First off, you do not need to define rf within your mod's code (and you should not redefine rf from within your mod, that will overwrite the table that we are using, basically deleting all the entries that were added before). Checking for the existence of rf and rf.custom_recycle may not be necessary, and you could just omit those lines and skip straight to table.insert

As for the table insertion function, we are inserting into the table rf.custom_recycle (the table that my mod uses to create manual recipes), and we are inserting this data into that table:

{"item", "example-item", "example-recipe"}

"item" defines the type of item (which is why I use "item-with-entity-data" for the hovercrafts mod), "example-item" should be the internal name of the item in question (under data.raw.item["item-name"]), and "example-recipe" should be the name of the recipe you are trying to assign to that item (under data.raw.recipe["recipe-name"])

EDIT: I updated the FAQ for this section, to hopefully clarify the wording. I realize that you probably want to use "armor" instead of "item" in your table.insert, wrong item type won't get properly matched

a month ago
(updated a month ago)

So the issue is just that this "Armour MK 4" is returning the wrong ingredients?

More or less that. Tho it happens to 20 or 30 of my 79 recipes.

Tho if i understand this correctly I would just add my 20-30 recipes to this list and your will mod auto fixes recipes automatically?

a month ago
(updated a month ago)

if data.raw.item["kj_gasbarrel"] and data.raw.recipe["kj_gasbarrel_fill"] then
table.insert(rf.custom_recycle, {"item", "kj_gasbarrel", "kj_gasbarrel_fill"})
end

So when i come to table.insert do i iterate all items in the recipe or... only the failing item which is all. Since my entire recipe output fails if bobs are active.

not sure if i have asked tho if you use discord i would be happy to chat in a voice chat if you have a time.

User:@Sgamez

a month ago

Another thing i notice is that many of my recipes get this in the log from you mod

2.290 Script @reverse-factory/func.lua:52: Recipe uses probability: par-solar-panel-mk9
2.290 Script @reverse-factory/func.lua:52: Recipe uses probability: par-solar-panel-mk10
2.292 Script @reverse-factory/func.lua:52: Recipe uses probability: par-laser-mk7
2.292 Script @reverse-factory/func.lua:52: Recipe uses probability: par-laser-mk8
2.292 Script @reverse-factory/func.lua:52: Recipe uses probability: par-laser-mk9
2.292 Script @reverse-factory/func.lua:52: Recipe uses probability: par-laser-mk10
2.294 Script @reverse-factory/func.lua:52: Recipe uses probability: par-shield-mk9
2.294 Script @reverse-factory/func.lua:52: Recipe uses probability: par-shield-mk10
2.294 Script @reverse-factory/func.lua:52: Recipe uses probability: par-belt-immunity-mk2

even tho i have no % based recipes

a month ago

I have tried in multiple load stages updates & final fixes still nothing.

Since both objects are in my mods or vanilla i don't see why I would use the if section. Also "rf." is undefined global
table.insert(rf.custom_recycle, {"armor", "par-armour-mk1", "modular-armor"})

a month ago
(updated a month ago)

I do have a Discord (same username, @Kryzeth), but I don't think a voice call would help any more than text chat. We also might be in different time zones that don't line up for a good meeting time.

What might help is having a copy of your in-progress mod so I can see what's happening internally, because I'm not sure I understand why the recipes you're defining are failing to match. Either your definition is improper/incorrect, or my detection logic is wrong, and the only way to know for sure is to have a copy of the mod in question

As for the log in question, it should only happen if it fails this check (i.e. if noProb is false at the end of this check):

function checkProbs(recipe,item)
    local noProb = true
    if recipe.results then
        if #recipe.results > 1 then noProb = false end
        for _, ingred in ipairs(recipe.results) do
            if ingred.probability then noProb = false end
        end
    end
    return noProb
end

The most likely reason would be if you are using multiple results in all of these recipes (which shouldn't be the case, since it sounds like they should only produce one item, not multiple). If you are defining recipes with multiple results, that could be the reason your recipes are all failing to match

a month ago
(updated a month ago)

https://github.com/SGZ-Creations/Power-Armour-Replacer/blob/master/Power-Armour-Replacer/structures/ReversFactory/ReversFixes.lua

Want to say the code that shows are the last one i tired tho I've attempted multiple things to try & have it work

Also when it come to time zones i can be fleksible. & supposedly i want my availability to be around 02:00-16:00 CET/CEST

a month ago

I don't think this is quite enough for me to tell what's going wrong, I need an actual copy of the mod so I can test it on my end. I need to like, actually debug it, seeing what the recipes and stuff look like before they hit my recycling functions.

29 days ago
(updated 29 days ago)

the mod was linked on that git page https://github.com/SGZ-Creations/Power-Armour-Replacer from here you would need to click the button named code & download a zipped version if the mod

24 days ago
(updated 24 days ago)

Okay, I finally got around to testing this, and I see exactly what's happening.

You added my mod as an optional dependency, which forces it to load first, and then you also make changes to recipes during data-final-fixes. You should technically be making those changes during data-updates, since bob's mods don't make any recipe changes (as far as I can tell) during final-fixes, so you don't need to either.

If you insist on making your mod perform recipe changes during final-fixes, then we need to reverse the load order so that my mod has an optional dependency on yours, instead of the other way around. If you make my mod run first, my mod will create the reverse recipes based on what has been altered before it. If your mod runs after that point, it changes the recipes, but my mod will never see those changes, because it never gets a chance to run afterwards.

None of the code attempts I mentioned above will work, specifically because when your mod enters its data-final-fixes, my mod has already done everything it can and will do; there is no further opportunity for my mod to make any changes. I recommend going with the first solution, moving your recipe changes to data-updates instead of data-final-fixes, but from my testing with 3.18.1 on github, just removing reverse-factory as an optional dependency made the recipes work properly.

You should probably do both of those things, honestly. No mods with recipe changes should have a dependency on this mod; this mod absolutely NEEDS to load LAST

22 days ago
(updated 22 days ago)

0.3.18-1 dose mot even have any of the code so testing that version was pointless.

You need to get the source or use my 0.3.23 on my discord sever found in my profile.

Tho I'll try removing the dependency and see.

22 days ago
(updated 22 days ago)

Fixed on my end for 0.3.24 of PAR.

Thank for the help.

22 days ago
(updated 22 days ago)

Deleted

22 days ago
(updated 22 days ago)

Not sure if you would be able to have increased output slots in settings for Reverse Factory would like to see setting on all 3 versions.

Unable to Reverse Armour mk10 since the recipe uses more then you 13 output slots my MK10 Armour has 18 items + 1 liquid = 19 output in you mod due to the solid liquids.

alternative from settings:
What i would love to see if your up for it is having a machine mk4 to show up if PA&R mod is active
then should it be possible make that machine have 20+ items output?

22 days ago
(updated 22 days ago)

I tried downloading the source and re-packing it as a mod myself (because the zip will not load as a mod on its own), but it kept complaining about something or other not found; it just did not work for me out of the box, so I used the most recent release that was available on the github. Trying to test again with 0.3.24 and the specific error appears to be with the dependency, Configurable Armour Suits:

__Power-Armour-Replacer__/graphics/icons/armour/power-armour-mk5.png not found

Renaming the png didn't work, since the Power Armour Replacer mod expects "icon-power-armour-mk5.png" in that location instead.

After fixing that error and trying to run with Reverse Factory, I got another error regarding "ammonia" in a recipe; it looks that stemmed from recipe/updates/fission_updates, line 326, where petroleum gas was being replaced. Changing it to "bob-ammonia" allowed everything to load.

Now that I look at it, it seems Power Armour Replacer was expecting a later version of Configurable Armour Suits than is available on the mod portal; that might have been the source of my issues (though the mod still seemed to be loading, I think its scripts were still running? Maybe they were being called from Configurable Armour Suits?)

Anyways regarding that last issue, output slot count is not static, it's automatically generated based on the allowed recipes. If it was less than expected, it is because my mod was still loading too early. I uploaded a version of Reverse Factory that has PAR as an optional dependency, that should force the load order, and should update to reflect the amount of results.

22 days ago
(updated 22 days ago)

Sorry that would be do to Configurable armour & suits also WIP so only available on my discord server until PA&R is done.
Because of thee error you got so other wont get it & start complaining in your case that is not your fault.

"~ Configurable-Armour-Suits >= 1.5.12",
Portal only have version 1.5.11

22 days ago
(updated 22 days ago)

Anyways regarding that last issue, output slot count is not static, it's automatically generated based on the allowed recipes. If it was less than expected, it is because my mod was still loading too early. I uploaded a version of Reverse Factory that has PAR as an optional dependency, that should force the load order, and should update to reflect the amount of results.

Update on that i updated your mod & Still having output issues.

Sorry for bothering you with all this mess.

22 days ago
(updated 22 days ago)

Hmm, in that case I'm not sure what the problem could be.. the logic for the number of output slots is, for every reverse recipe that is created, when it is created successfully, it checks the number of ingredients that went into that recipe, and if it is larger than the number of output slots, it sets the number of output slots to the number of ingredients instead. Each additional tier also checks the tiers below it, to ensure that every subsequent tier of Reverse Factory has the same or more output slots than the tier before it.

It would really help if I had a working copy of your mod (or rather mods plural, since I need both of them) to see what is actually happening. You have my Discord username already, so as long as you are in any of the big Factorio servers, you should be able to message me and send over your pre-packed, in-development versions of the mod (hopefully it's not larger than the filesize limit) so that I can run some debug commands

New response