Page 1 of 1

Add a "blueprint as" property

Posted: Tue Mar 26, 2019 12:19 pm
by GotLag
Is it feasible to add a field to prototypes to allow that entity/tile to be replaced with another entity/tile in blueprints? There are times when a mod needs to swap out an entity at some point after it's built, and this currently breaks blueprints made after that swap.

Three example uses:
  • Make all vanilla land tiles blueprint as landfill, so a blueprint can be made of any part of a factory and automatically include landfill through the simple expedient of ticking "include tiles", instead of having to be blueprinted on an area that's already been entirely landfilled.
  • Allow auto-generated custom locomotive entities from this mod to blueprint as the normal, buildable versions.
  • A mod that adds different versions of rails for concreted/paved surfaces and swaps them out automatically as the rails are built or tiles are added/removed, but uses the same rail item to build them all

Re: Add a "blueprint as" property

Posted: Tue Mar 26, 2019 3:40 pm
by DaveMcW
The workaround is to do a search/replace in events.on_player_configured_blueprint. But I agree a property would be very convenient.

Re: Add a "blueprint as" property

Posted: Tue Mar 26, 2019 4:07 pm
by GotLag
I seem to be missing something because I can't work out where to find/replace in that situation. All that event gives me is the player index, and I don't see anything in the LuaPlayer API that is useful here.

Re: Add a "blueprint as" property

Posted: Tue Mar 26, 2019 4:15 pm
by DaveMcW
The blueprint is in player.cursor_stack

Re: Add a "blueprint as" property

Posted: Tue Mar 26, 2019 4:45 pm
by GotLag
Okay, that also works with copy-paste if you use events.on_player_setup_blueprint and make the appropriate checks, thanks.

Still, the entities/tiles need to have (hidden, non-craftable) items defined to place them for them to be selectable for blueprints/copying