How to access temporary BP in player's hand?

Place to get help with not working mods / modding interface.
targetsan
Burner Inserter
Burner Inserter
Posts: 12
Joined: Tue Jan 05, 2021 7:47 pm
Contact:

How to access temporary BP in player's hand?

Post by targetsan »

Hello!

I'm trying to revive "Landfill Everything" mod. While it's made mostly working by fixes presented in this post; viewtopic.php?p=528357#p528357 , it's now unable to operate on temporary BPs or BPs opened from library, unline in 0.18 times. This is caused specifically by the fact that player.cursor_stack.valid_for_read is false for such "item stacks". And player's get_blueprint_entities() isn't enough since we also need to both get BP's tiles and set them. Could you please point out to API which allows to access temporary BP in hand as actual BP?

Thanks.
Xorimuth
Filter Inserter
Filter Inserter
Posts: 704
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: How to access temporary BP in player's hand?

Post by Xorimuth »

I'm sure more knowledgeable people can post here and confirm, but I'm pretty sure that you simply cannot do what you are trying to do anymore. The blueprint library is completely off-limit to mods.
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
targetsan
Burner Inserter
Burner Inserter
Posts: 12
Joined: Tue Jan 05, 2021 7:47 pm
Contact:

Re: How to access temporary BP in player's hand?

Post by targetsan »

Well, I'm not trying to mess with BP library. I just want to modify BP picked from there as if it was a temporary.
Xorimuth
Filter Inserter
Filter Inserter
Posts: 704
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: How to access temporary BP in player's hand?

Post by Xorimuth »

targetsan wrote: Tue Jan 05, 2021 9:27 pm Well, I'm not trying to mess with BP library. I just want to modify BP picked from there as if it was a temporary.
I was sort of wrong: see https://lua-api.factorio.com/latest/Lua ... _blueprint
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
targetsan
Burner Inserter
Burner Inserter
Posts: 12
Joined: Tue Jan 05, 2021 7:47 pm
Contact:

Re: How to access temporary BP in player's hand?

Post by targetsan »

Thanks for the link. Unfortunately I already know about this API, and it has two severe limitations. First, it's unclear how to modify such BP, as it provides only getter methods. Second, it doesn't seem to provide access to BP tiles, as there's only get_blueprint_entities and nothing similar to LuaItemStack.get_blueprint_tiles
Daeruun
Inserter
Inserter
Posts: 43
Joined: Thu May 04, 2017 8:37 pm
Contact:

Re: How to access temporary BP in player's hand?

Post by Daeruun »

I'm working on a similar problem, but only reading. (see here)
With some quirks I can get the active blueprint from a library-stored book or blueprint.
But only the entities, not the tiles, as mentioned above. And I could not (yet) come up with a way to get the other blueprints from a library-stored book.
There is a set variant of the mentioned function, that you can use on a target blueprint that you could create by calling the paste command...
For your uses this could be suitable, I think:

Code: Select all

local temp_blueprint = player.get_blueprint_entities()
player.activate_paste()
blueprint = player.cursor_stack
blueprint.set_blueprint_entities(temp_blueprint)
Now the active blueprint that was in the cursor is in the cursor again - as a new temporary blueprint, that can be handled like any blueprint stored in the user-inventory.

There seems to be no way to get the original link to the library back into the stack, as far as I can see...
Post Reply

Return to “Modding help”