Export currently held blueprint library object to item

User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 574
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Export currently held blueprint library object to item

Post by raiguard »

I swear I made a post about this before, but cannot find it for the life of me. Hopefully my searching powers aren't failing me.

The new blueprint library works well for users, but not for mods. We can get the entities of the currently held library blueprint, but there's no way to get anything else about it, forcing the user to convert the blueprint into an item (by placing it in their inventory or making a copy) before mods can do anything with it.

My proposal is simple: provide a function on LuaPlayer to detect if they're holding any library object (blueprint, upgrade, or decon planner). Then, add another LuaPlayer function to export the currently held library object to a given LuaItemStack. My usecase would be to call this every time the player's cursor changes if they're holding a library object, so I can read properties about the held object by looking at the LuaItemStack after calling the function, and make changes to the item as well.
Don't forget, you're here forever.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Export currently held blueprint library object to item

Post by eradicator »

Utterly seconded!

I made a mod that adds more wildcard filters to the decon planner (i.e. deocratives) and it works fine with items. But I need to read the whitelist/entity_filters which isn't possibly from library records. Given the sheer number of properties that might be relevant (entity_filters, tile_filters, entity_filter_mode, tile_filter_mode, tile_selection_mode, etcpp...) converting to a real LuaItemStack and using the existing API seems indeed to be the best approach to keep it simple and future-proof.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Skjolbir
Burner Inserter
Burner Inserter
Posts: 19
Joined: Thu Apr 23, 2020 2:04 pm
Contact:

Re: Export currently held blueprint library object to item

Post by Skjolbir »

Huge +1

oof2win2
Long Handed Inserter
Long Handed Inserter
Posts: 56
Joined: Wed Nov 18, 2020 8:13 am
Contact:

Re: Export currently held blueprint library object to item

Post by oof2win2 »

+1. Making a mod that is attempting to save blueprints across multiple servers with external help, and it would be much more user-friendly if users could just drag and drop a BP from their library and not just a BP item.

kajacx
Inserter
Inserter
Posts: 20
Joined: Sun Mar 10, 2019 11:08 am
Contact:

Re: Export currently held blueprint library object to item

Post by kajacx »

Very much agree. I need to read if the currently held blueprint is absolutely positioned or not. There already is a property on the player https://lua-api.factorio.com/next/LuaPl ... t_to_setup, but it is nil in the on_pre_build event when player is building from a blueprint that isn't in their inventory.

azaghal
Inserter
Inserter
Posts: 35
Joined: Sat Jun 27, 2020 11:13 am
Contact:

Re: Export currently held blueprint library object to item

Post by azaghal »

Instead of opening up a new request, I wanted to chime in on this one with another use case that would benefit from being able to work with blueprints from a library. If this would be better posted separately, please do let me know (but someone has already been kinda redirected to this topic on a related issue, so figured it's better to post here).

Currently, when trying to inspect the content of quick bar slots, it is impossible to figure out if a slot might contain a blueprint from the player/game library. In fact, when invoking the LuaPlayer.get_quick_bar_slot function, if the slot contains blueprint from a library, the function will return nil, which can cause problems for mods that might want to change the state of the slot (or, at the very least, ignore the slot if it is a blueprint).

This has particularly happened to me when trying to implement a small patch for the Quick Swap mod to at least ignore the blueprints when vertically swapping the quick bar shortcuts.

While I understand that there are deep technical limitations on why the blueprints cannot be manipulated as LuaItemStack's, in the interim it would be useful to at least provide modders with a way to get at least some information about the blueprints in the library.

We already have the LuaControl.get_blueprint_entities, and perhaps we could at least get something like a LuaControl.get_blueprint_tiles and LuaPlayer.is_quickbar_slot_blueprint(slot_number) functions as a work-around?

P.S.
Another mod that would benefit from being able to retrieve tile/blueprint information, would be Blueprint Signals (continued).

brenny
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Feb 24, 2018 11:06 pm
Contact:

Re: Export currently held blueprint library object to item

Post by brenny »

+1 would be a huge advantage to many mods
including being able to tell what blueprint/deco/upgrader is linked to from the quickbar as in post from azaghal

spenczar
Manual Inserter
Manual Inserter
Posts: 1
Joined: Fri Dec 02, 2022 7:14 pm
Contact:

Re: Export currently held blueprint library object to item

Post by spenczar »

I really want this too. I want to update https://mods.factorio.com/mod/GhostOnWater to support rewrites of library blueprints.

azaghal
Inserter
Inserter
Posts: 35
Joined: Sat Jun 27, 2020 11:13 am
Contact:

Re: Export currently held blueprint library object to item

Post by azaghal »

Coming back to this request, I have another use-case for being able to access deconstruction and upgrade planners from game/player library.

The mod ConstructionPlannerContinued (which I maintain) allows players to plan-out parts of the base using blueprints without any entity being built by construction bots until the ghosts are explicitly approved. Behind the scenes, the code relies on switching the ghost entity force to prevent building by player's own force.

For each such unapproved ghost, a placeholder entity is created that the player can then interact with using deconstruction planner. The mod has logic that handles use of deconstruction planners where the force for unapproved ghosts in selected area gets swapped back to player's own, and then the deconstruction planner gets reapplied on the same area - thus effectively removing the unapproved ghosts.

However... This, once again, does not function as intended with the deconstruction planners in the game/player library - such deconstruction planners cannot be used to deconstruct an area, and no information whatsoever can be ascertained about them. For the time being, since deconstruction planners can have filters/inversion etc, the mod simply refuses to remove unapproved ghosts in deconstructed area if the planner comes from the game/player library (taking the safest route).

Another use-case for the same mod would be ability to access information about the upgrade planner. Currently the mod does not apply upgrades to unapproved ghosts, but theoretically this should be possible. But if I go ahead and implement this, it'll end-up in same situation where the upgrade planners from game/player library would be unusable due to similar limitations that exists for the blueprints and deconstruction planner.

So, once again I would like to ask for providing some ability to at least get more (preferably all) information about the currently held blueprint/deconstruction/upgrade planner, if it is not possible to somehow gain access to entire stack or copy of the stack. Or, the very least, could we at least get some form of more official answer to this request?

P.S.
And don't take that last paragraph as me being ungrateful, I really appreciate all the effort Wube has put in into making the game modable from the get-go and with fully documented interface - but there's a lot of useful convenience mods out there that simplify some mundane tasks with blueprints :)

User avatar
Locane
Fast Inserter
Fast Inserter
Posts: 120
Joined: Fri Jan 04, 2019 8:46 am
Contact:

Re: Export currently held blueprint library object to item

Post by Locane »

As a user of the Personal Logistics Template mod, I would also like to see this.

This would enable an "update to current blueprint" feature, instead of forcing the user (me) to delete and re-create a new one every time I want to modify the Template.

GAGAMURAGAMIR
Manual Inserter
Manual Inserter
Posts: 2
Joined: Wed Apr 12, 2023 4:42 pm
Contact:

Re: Export currently held blueprint library object to item

Post by GAGAMURAGAMIR »

Another second to this request, registred on this forum specifically to post this after few hours of unfruitful attempts to get the name of a blueprint from a library that a player is attempting to build. Would really like this feature as I am building a mod for train powered base construction
Last edited by GAGAMURAGAMIR on Wed Apr 12, 2023 4:49 pm, edited 1 time in total.

safthelamb@gmail.com
Burner Inserter
Burner Inserter
Posts: 10
Joined: Tue Aug 22, 2023 8:45 am
Contact:

Re: Export currently held blueprint library object to item

Post by safthelamb@gmail.com »

Another bump for this! I have a similar request for a use case documented here: viewtopic.php?f=28&t=108482&sid=5e02a96 ... f2fa871f2f

safthelamb@gmail.com
Burner Inserter
Burner Inserter
Posts: 10
Joined: Tue Aug 22, 2023 8:45 am
Contact:

Re: Export currently held blueprint library object to item

Post by safthelamb@gmail.com »

Update: While it's very roundabout and requires handling blueprint rotation manually, I was able to come up with a roadmap for a solution within the existing API. I've gotten a proof-of-concept underway locally, and I've documented my current findings here: viewtopic.php?f=28&t=108482

Subject314159
Burner Inserter
Burner Inserter
Posts: 8
Joined: Thu Oct 12, 2023 8:53 pm
Contact:

Re: Export currently held blueprint library object to item

Post by Subject314159 »

Adding my +1 here too! Personally I never store blueprints in game (character, chest, entity, whatever) but always in my personal blueprint library. Almost all blueprint altering mods will benefit from this feature.

User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 574
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: Export currently held blueprint library object to item

Post by raiguard »

Blueprint library records will be accessible to mods in 2.0. Records in "my blueprints" are read-only, while records in "game blueprints" are read/write.
Don't forget, you're here forever.

aka13
Filter Inserter
Filter Inserter
Posts: 793
Joined: Sun Sep 29, 2013 1:18 pm
Contact:

Re: Export currently held blueprint library object to item

Post by aka13 »

raiguard wrote:
Tue Oct 24, 2023 11:47 pm
Blueprint library records will be accessible to mods in 2.0. Records in "my blueprints" are read-only, while records in "game blueprints" are read/write.
What greater flex can be made, than implementing your own request on a game?
This remains to be seen
Pony/Furfag avatar? Opinion discarded.

User avatar
Hares
Filter Inserter
Filter Inserter
Posts: 299
Joined: Sat Oct 22, 2022 8:05 pm
Contact:

Re: Export currently held blueprint library object to item

Post by Hares »

raiguard wrote:
Tue Oct 24, 2023 11:47 pm
Blueprint library records will be accessible to mods in 2.0. Records in "my blueprints" are read-only, while records in "game blueprints" are read/write.
Will the currently held/opened/updated "my blueprint" item be writable? That's the most common use case currently (when you update an existing BP in the library).

User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 574
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: Export currently held blueprint library object to item

Post by raiguard »

Hares wrote:
Mon Mar 04, 2024 3:56 pm
Will the currently held/opened/updated "my blueprint" item be writable? That's the most common use case currently (when you update an existing BP in the library).
I have not solved this issue yet but it is on my to-do for the 2.0 release, rest assured.
Don't forget, you're here forever.

kajacx
Inserter
Inserter
Posts: 20
Joined: Sun Mar 10, 2019 11:08 am
Contact:

Re: Export currently held blueprint library object to item

Post by kajacx »

That's nice to hear. This is a bit of an XY problem, where the real problem is that there is no (easy) way to read "built" entities when using a blueprint.

You can read the entities in the blueprint, then see its size, it's orientation and flipping, and then work everything out yourself, but it's a lot of work and it's prone to error, especially with wierdly shaped objects like the offshore pump, not to mention absolute position snapping, or the entire blueprint being snapped to a 2x2 grid because it has rails, and probably more.

It would be best if you could read resolved position and rotation of all the entities in a currently held blueprint. The game already has to calculate it, so "just" exposing the already existing information to the modding API shouldn't be that much work.

Post Reply

Return to “Implemented mod requests”