Page 1 of 1

LuaRecord::get_active_index not usable

Posted: Sat Feb 15, 2025 5:39 pm
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

Re: LuaRecord::get_active_index not usable

Posted: Thu Feb 27, 2025 3:12 pm
by PennyJim
Fixed in 2.0.35