Page 1 of 1

How to access temporary BP in player's hand?

Posted: Tue Jan 05, 2021 8:02 pm
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.

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

Posted: Tue Jan 05, 2021 9:25 pm
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.

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

Posted: Tue Jan 05, 2021 9:27 pm
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.

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

Posted: Sat Jan 16, 2021 11:27 am
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

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

Posted: Sun Jan 17, 2021 12:17 pm
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

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

Posted: Sat Jan 30, 2021 6:11 pm
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...