Page 1 of 1

`LuaRecord.is_preview` and the `on_pre_build` event.

Posted: Thu Sep 11, 2025 9:39 pm
by The_LORD_thy_GOD
(In the #mod-dev-help discord channel, Bilka asked for a forum post to be made about this issue. Link to the original discord discussion: here)

We received the following multiplayer crash report:
09-11-2025, 14-34-14.png
09-11-2025, 14-34-14.png (92.67 KiB) Viewed 222 times


Upon analysis, we found the crash is occurring in the `on_pre_build` event for a blueprint where `is_preview` is `true`.

Questions arose about the meaning of the `LuaRecord.is_preview` flag and how it could possibly be `true` for a blueprint that was actually being built. As `on_pre_build` is the "last chance" event (at least as far as I know) for mods to look at what entities a blueprint will build, it would be preferable if blueprint entities were fully readable at that point.

Re: `LuaRecord.is_preview` and the `on_pre_build` event.

Posted: Fri Sep 12, 2025 6:46 am
by Bilka

Re: `LuaRecord.is_preview` and the `on_pre_build` event.

Posted: Fri Sep 12, 2025 7:40 am
by Bilka
As suspected on discord, this is indeed happening because the record you get is a blueprint book that is considered a preview, but the selected blueprint is not a preview and getting placed. For 2.0.67 we've added LuaRecord::get_selected_record() which will get you the selected single blueprint record from the book even if the book is a preview. (That record may still be in preview generally, but not in this event.) Thanks for the assistance in debugging this!

Note for future readers: Preview means that it's a blueprint or book from a player's library that hasn't been loaded to the game state yet, so usually seen in multiplayer games.