Blueprinting Custom Buildings

Place to get help with not working mods / modding interface.
ZachAttackary
Inserter
Inserter
Posts: 20
Joined: Thu Oct 22, 2015 11:56 pm
Contact:

Blueprinting Custom Buildings

Post by ZachAttackary »

Hello Everyone! I am getting into modding for the first time after playing this game for quite some time. I have a decent programming background, so I get the basics.
I am making a custom building that needs to save some data with it. This is all fine and dandy until I make a blueprint of said building to duplicate it. Is there some way of saving your custom data inside the blueprint, so when the copy of the building gets placed it has the data from its source building?

Thanks in advance!
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3718
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Blueprinting Custom Buildings

Post by DaveMcW »

That is not supported by the blueprint system.

There is a hack you could try. Make constant-combinator your base entity type; add extra entities in on_built_entity/on_robot_built_entity. This would give you combinator slots for data transfer.

Or post in Modding inferface requests.
ZachAttackary
Inserter
Inserter
Posts: 20
Joined: Thu Oct 22, 2015 11:56 pm
Contact:

Re: Blueprinting Custom Buildings

Post by ZachAttackary »

Oh interesting. I'm struggling to see how you could use this for data transfer. if when you place the item it replaces the item with another item, how would you capture the data from the constant-combinator? If there was a way to leave the constant-cominator there, but hidden, so I could still access the data, is there a way to make the blueprint not grab the visible actual object and only grab the data object(the hidden constant-combinator?). The problem is in my situation its not data that is ubiquitous between machines, its machine specific.

For anyone else looking for a way to do this, here is the workaround I've thought of:

Have a gui for your mod that has a checkbox for full data blueprinting. What this checkbox would do is when it is activated, using a deconstruction planner would instead, using the on_marked_for deconstruction build up a list of all the items in deconstruction zone, essentially building up a table with the same structure that .get_blueprint_entities() would return. Then you could search the players inventory, replacing an empty blueprint these values. You then follow up by demarking them all for deconstruction. The reason this is useful is because you gain access to each of the buildings as the blueprint is built. You could save data on these buildings, and then store this data linked to the blueprint values using a table. When a blueprint is placed, you can check the blueprint for matching any of your saved blueprints with extra data and if you find one, add the extra data to the machines as placed! Little hacky, but in theory should work rather well.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3718
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Blueprinting Custom Buildings

Post by DaveMcW »

ZachAttackary wrote:is there a way to make the blueprint not grab the visible actual object and only grab the data object(the hidden constant-combinator?).
flags = {"not-on-map"}
ZachAttackary
Inserter
Inserter
Posts: 20
Joined: Thu Oct 22, 2015 11:56 pm
Contact:

Re: Blueprinting Custom Buildings

Post by ZachAttackary »

Dave! You are a genius! I've spent some time thinking through this solution and I totally can use it! Way cool! Thanks for the help!!!
ZachAttackary
Inserter
Inserter
Posts: 20
Joined: Thu Oct 22, 2015 11:56 pm
Contact:

Re: Blueprinting Custom Buildings

Post by ZachAttackary »

DaveMcW wrote:flags = {"not-on-map"}
This doesn't appear to stop blueprints from seeing the entity. are you positive this flag does what you think it does? I looked online and I can't seem to find any information on it.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3718
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Blueprinting Custom Buildings

Post by DaveMcW »

Doh, I didn't actually test it. :( I guess you need to find a way to delete the extra blueprint.
Post Reply

Return to “Modding help”