Blueprintability
jimrandomh opened this issue · 6 comments
It would be very nice if you could blueprint a factory from the outside, place the blueprint, and have the inside automatically filled somehow.
Creating an issue to track this, because I'm currently working on it. I think I've figured out how to make it work (though it certainly involves some hacks!)
Rough implementation plan:
First thing is to make factories serializable, so that, as long as we can find somewhere to stick an extra string into blueprints, we can record factory contents. As a proof of concept for this, I made it so that if you paste-settings from one factory to another (ie shift+rightclick then shift+leftclick), it makes a temporary blueprint of the contents of the first factory, and uses it to fill the second factory with blueprint ghosts. This part is working in my development environment.
Next, create a new item, factory-construction-requester-chest, which is a logistic requester chest that periodically looks for a factory next to itself, looks inside that factory for blueprint ghosts, then uses its contents to revive those ghosts and adjusts its logistic requests according to what ghosts are remaining. Currently working on this bit.
Next intercept blueprints at the moment of creation, and if they contain a factory-construction-requester-chests, replace it with factory-contents-marker. Factory-contents-marker inherits programmable-speaker, so it has a text field to abuse for storing a blueprint string. Whenever a factory is placed, check for adjacent factory-contents-markers, and if one is found, unpack the blueprint inside and turn it back into a factory-construction-requester-chest.
Wow, that's a pretty solid method. Be careful about the programmable-speaker text field though, it may have a restrictive character limit or may receive one in the future without warning.
Proof of concept is working! I successfully blueprinted a factory with a construction-requester chest next to it, placed the blueprint, and got a factory full of ghosts with a construction-requester chest requesting the right items, and which revived those ghosts when the chest was filled.
There was indeed a max length for the programmable speaker's text field, but it seems to only be enforced through the user interface, so mucking with a blueprint can produce one with a warning that's longer than it's supposed to be. This might break in a later version, so I'll warn the Factorio devs about it.
Issues left to address:
Blueprints are limited to a single non-recursive factoryConstruction requester chest updates when you rotate it, rather than on a timer like it shouldConstruction requester chests only look at the factory immediately inside, they don't handle recursionSearch for a chest touching a factory actually searches for chests within radius 12, rather than calculate the right area- Blueprint modification is done when you confirm the blueprint, rather than when you drag-create it, so if you export a blueprint to string from the confirmation dialog without confirming first it won't have factory content information in it
- Blueprints do not contain building power settings or connection settings
The construction-requester-chest thing needs in-game documentation (via item and technology descriptions)- New strings will need localization to the other Factorissimo2-supported languages (DE,KO,PL,RU).
The factory-construction-requester-chest is reusing the graphic from factory-requester-chest (the one that finds initialized factories within your logistic system). I'm not sure whether it's better to make a new graphic for it, or to take out the factory-requester-chest (which is kind of useless). I don't plan on doing any graphic design for this myself.
Also, I have (locally, not on github) a "tiny" factory size (4x4 on the outside, 15x15 on the inside). This is much more usable/sensible when combined with blueprints; I'm envisioning a small factory building that is, for example, an "engine assembler" and acts similarly to an actual assembler. This needs a graphic; I reused the small-factory graphic, scaled to half size. Do you know who made the three original factory images, and whether they'd be up for drawing one more?
I made the three factories myself in Blender, but I'm rather swamped with other stuff at the moment (as you can see by my lack of recent commits despite a growing issue list) and don't really have time for stuff like that in the near future. Also I'm not sure that a such tiny factory would even be worth the script overhead.