(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:
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.
`LuaRecord.is_preview` and the `on_pre_build` event.
-
- Burner Inserter
- Posts: 6
- Joined: Sun Nov 10, 2024 5:23 pm
- Contact:
Re: `LuaRecord.is_preview` and the `on_pre_build` event.
Lua code for reference: https://github.com/project-cybersyn/bpl ... 4e594f6180
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: `LuaRecord.is_preview` and the `on_pre_build` event.
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.
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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.