Page 1 of 1

[2.0.65] Cannot read "is_blueprint_preview" for blueprint books

Posted: Mon Sep 01, 2025 8:48 pm
by robot256
Summary: If you don't check if a blueprint-book record is a preview, then you get the error "BlueprintRecord cannot be read while it is a preview." when attempting to read LuaRecord::contents to get the blueprints inside the book. HOWEVER, the game throws an error when you try to read "is_blueprint_preview" on a LuaRecord of type blueprint-book. My guess is that a simple change is needed to allow checking the preview state of blueprint-book, upgrade-planner, and deconstruction-planner LuaRecords.

What I did:

First Error:
1. Download Cargo Ships version 2.0.21 from the mod portal.
2. Start a server with Cargo Ships enabled.
3. In single player, create a blueprint book with a blueprint inside it. It can be any kind of blueprint. Place the blueprint book in your "My Blueprints" library.
4. Connect to the server. Open your blueprint library and pick up the book from My Blueprints.
5. It should immediately crash with the error "BlueprintRecord cannot be read while it is a preview."

Bug in the attempted fix:
1. Download the attached version of Cargo Ships.
2. Start a server with this version of Cargo Ships enabled.
3. Make sure the same blueprint book is in your My Blueprints library.
4. Connect to the server. Open your blueprint library and pick up the book from My Blueprints.
5. It should immediately crash with the error "Record is not a BlueprintRecord." on line __cargo-ships__/logic/pump_placement.lua:95: in function 'is_holding_pump'

Re: [2.0.65] Cannot read "is_blueprint_preview" for blueprint books

Posted: Mon Sep 01, 2025 9:00 pm
by boskid
Given that you are trying to read a value that is documented as woking only on blueprints to check state of a book, i am classifying this as a modding interface request.

Re: [2.0.65] Cannot read "is_blueprint_preview" for blueprint books

Posted: Tue Sep 02, 2025 6:44 am
by boskid
In 2.0.66 there will be LuaRecord::is_preview that is not limited to blueprints.