Page 1 of 1

Export currently held blueprint library object to item

Posted: Wed Feb 17, 2021 7:16 am
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.

Re: Export currently held blueprint library object to item

Posted: Tue Aug 17, 2021 6:08 pm
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.

Re: Export currently held blueprint library object to item

Posted: Sun Nov 14, 2021 11:01 pm
by Skjolbir
Huge +1

Re: Export currently held blueprint library object to item

Posted: Tue Nov 16, 2021 9:12 pm
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.

Re: Export currently held blueprint library object to item

Posted: Sun Jan 16, 2022 2:02 pm
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.

Re: Export currently held blueprint library object to item

Posted: Sat Jul 09, 2022 3:28 pm
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).

Re: Export currently held blueprint library object to item

Posted: Wed Jul 13, 2022 6:06 am
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

Re: Export currently held blueprint library object to item

Posted: Fri Dec 02, 2022 7:16 pm
by spenczar
I really want this too. I want to update https://mods.factorio.com/mod/GhostOnWater to support rewrites of library blueprints.

Re: Export currently held blueprint library object to item

Posted: Mon Feb 13, 2023 12:09 am
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 :)

Re: Export currently held blueprint library object to item

Posted: Mon Mar 13, 2023 6:40 am
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.

Re: Export currently held blueprint library object to item

Posted: Wed Apr 12, 2023 4:48 pm
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

Re: Export currently held blueprint library object to item

Posted: Fri Sep 01, 2023 11:56 am
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

Re: Export currently held blueprint library object to item

Posted: Sat Sep 02, 2023 7:07 am
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

Re: Export currently held blueprint library object to item

Posted: Fri Oct 13, 2023 5:00 pm
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.

Re: Export currently held blueprint library object to item

Posted: Tue Oct 24, 2023 11:47 pm
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.

Re: Export currently held blueprint library object to item

Posted: Wed Oct 25, 2023 12:09 pm
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

Re: Export currently held blueprint library object to item

Posted: Mon Mar 04, 2024 3:56 pm
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).

Re: Export currently held blueprint library object to item

Posted: Mon Mar 04, 2024 5:03 pm
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.

Re: Export currently held blueprint library object to item

Posted: Mon Mar 04, 2024 6:46 pm
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.