[2.0] Get blueprint in cursor on_pre_build

Place to get help with not working mods / modding interface.
kubiix
Burner Inserter
Burner Inserter
Posts: 10
Joined: Mon Jul 20, 2020 10:54 am
Contact:

[2.0] Get blueprint in cursor on_pre_build

Post by kubiix »

I am trying to get LuaRecord of blueprint held in cursor during op_pre_build

player.cursor_record.get_blueprint_entities() works fine when in cursor is single blueprint

but when i take whole blueprint book and try to place the selected blueprint from it, player.cursor_record.get_blueprint_entities() fails (Record is not a BlueprintRecord.)

From the LuaRecord of BlueprintBook i can access contents with all blueprints in the book, but where is no info which of them is the one which is selected

Someone pointed me to cursor_stack, but it is empty for both scenarios - is there way to call get_blueprint_entities() on bleprint from book ?

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

Re: [2.0] Get blueprint in cursor on_pre_build

Post by azaghal »

I am actually baffled by this one as well. There are multiple mods I have which heavily depend on being able to access blueprint entities no matter where they are stored, and this kinda kills off a lot of their usability.

This surely must be some kind of oversight? It would be useful even if we could get some kind of "index" exposed for retrieving active blueprint from LuaRecord.contents.

Best regards,
Branko
azaghal
Inserter
Inserter
Posts: 36
Joined: Sat Jun 27, 2020 11:13 am
Contact:

Re: [2.0] Get blueprint in cursor on_pre_build

Post by azaghal »

In fact, from what I can tell, it is not possible to do anything similar with the LuaItemCommon (when a BlueprintBookItem) either. We do have a LuaItemCommon.active_index if it is a blueprint book, but nothing to do with it? :)

Best regards,
Branko
azaghal
Inserter
Inserter
Posts: 36
Joined: Sat Jun 27, 2020 11:13 am
Contact:

Re: [2.0] Get blueprint in cursor on_pre_build

Post by azaghal »

And to anyone else who might face-palm like myself, at least for the inventory book access, active blueprint from the blueprint book held in inventory can be grabbed with:

Code: Select all

stack.get_inventory(defines.inventory.item_main)[stack.active_index]
I just failed to realise that books expose their inner content as regular inventory (got thrown off by the whole LuaRecord.contents thing).

If any of the devs are reading this, would it be possible to get a mention of this fact under the LuaItemStack.active_index documentation?

Best regards,
Branko

P.S.
And sorry for side-tracking this thread.
Post Reply

Return to “Modding help”