LuaRecord::get_active_index not usable

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
kryojenik
Inserter
Inserter
Posts: 46
Joined: Fri Jun 26, 2020 8:18 pm
Contact:

LuaRecord::get_active_index not usable

Post by kryojenik »

LuaRecord::get_active_index() was added in 2.0.29, presumably to allow working with blueprint book stored in players or game libraries. This LuaRecord is also now (2.0.34) the way we interact with updated blueprints in on_player_setup_blueprint (88100).

If picking up a blueprint book from the library, using shift-scroll wheel to select a print, and then placing it down - the LuaRecord you get in your events is the blueprint-book you picked up out of your library. LuaRecord::get_active_index() returns the "slot" in the blueprint-book of the selected blueprint. This is similar to LuaItemCommon::active_index. However, in LuaRecord::contents[] the indices are sequential without gaps. There is no analogue to LuaItemCommon::get_inventory() to get the blueprint(-book) at the book's slot location. Thus, there is no relationship between the result of LuaRecord::get_active_index() and an actual LuaRecord in the LuaRecord::contents[] table.

Showing the selected blueprint is in "slot" 3 of the blueprint-book
pic
Command to get the active index returns "3", but using that index to get the actual blueprint is unsuccessful since there is no key "3" in the LuaRecord::contents[] table. The blueprint in question is actually at key "2".
pic
pic
User avatar
PennyJim
Fast Inserter
Fast Inserter
Posts: 123
Joined: Wed Jan 18, 2023 3:49 am
Contact:

Re: LuaRecord::get_active_index not usable

Post by PennyJim »

Fixed in 2.0.35
Post Reply

Return to “Modding interface requests”