Rewriting blueprints when moving entities

Place to get help with not working mods / modding interface.
User avatar
hgschmie
Fast Inserter
Fast Inserter
Posts: 113
Joined: Tue Feb 06, 2024 5:18 am
Contact:

Rewriting blueprints when moving entities

Post by hgschmie »

Bit of a longer setup:

There is a mod. Let's call it "miniloader". The mod was not released for 2.0 but obviously there are lots of saves that use that mod. Entities from that mod are in blueprints in those saves. They usually show up e.g. as

Code: Select all

             {
                "entity_number": 23,
                "name": "fast-miniloader-inserter",
                "position": {
                    "x": 43.5,
                    "y": 1.5
                },
                "direction": 4,
                "override_stack_size": 1,
                "drop_position": [
                    0.19921875,
                    -0.25
                ],
                "pickup_position": [
                    -0.80078125,
                    0
                ]
            },
When loading such a save into 2.0, the entities are gone from the blueprint (because there is no mod backing them).

Enter a new mod. Let's call it "miniloader (redux)". That mod has a startup setting that supports "migrate existing miniloaders from 1.1 to this mod". It does so by creating entities with the correct names (in this case "fast-miniloader-inserter") so that loading the game restores the entities and then migrating them to the new entities and destroying the old ones. Works *great* for any entity that is in the game.

But it does not for blueprints. Any blueprint that gets inspected at startup has already the entities from the old "miniloader" mod removed. So a blueprint that contains four miniloaders and has a total of 10 entities will show up with six.

If I load the actual "miniloader" module (I said "it was not released", I do have a local, q'n'd port) first (so that the "miniloader-redux" does not have to create these entities but can use the ones owned by the old mod), it still works *great* for any entity but now it also works for the blueprints (the same blueprint that shows up with the four miniloaders removed now has all entities present.

So there is some difference in blueprints when they reference an entity from a mod, that mod gets removed and a new mod gets loaded that has the same entity (type and name).

Is there a way to work around this? For a lot of never-released-for-2.0 mods, it is possible to migrate to other mods but I also have (literally hundreds) of blueprints that I can not migrate but have to fix manually.

Should I report this as a bug or is there some mod specific workaround?

Relevant migration code is here: https://github.com/hgschmie/factorio-mi ... ration.lua
Natha
Filter Inserter
Filter Inserter
Posts: 253
Joined: Sun Mar 15, 2015 1:48 pm
Contact:

Re: Rewriting blueprints when moving entities

Post by Natha »

What happens if you temporarily name your "miniloader-redux" mod to "miniloader"? Does that work?
Post Reply

Return to “Modding help”