editable LuaRecord.contents and library tables - multi-server blueprint sync (Clusterio)

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
ILLISIS
Inserter
Inserter
Posts: 46
Joined: Wed Feb 09, 2022 10:49 am
Contact:

editable LuaRecord.contents and library tables - multi-server blueprint sync (Clusterio)

Post by ILLISIS »

What
A way for a mod to add a new record to the Game blueprints library from an export string (or from a blueprint item), and to remove one. Today a script can read and edit records that already exist, but it can't create or delete one.

Why
I am developing for Clusterio Gridworld(https://www.youtube.com/watch?v=BnOsXpc4CbU) and will be running a multi-server cluster where every server is a separate save. I'd like each server's Game blueprints shelf to share the cluster's blueprints. Reading, exporting and updating are possible. Adding a blueprint that another server's shelf has, or removing one, isn't.

What we use today (tested on 2.1.21)
  • game.blueprints + LuaRecord::export_record(): read and export every entry.
  • Editing an existing record: LuaRecord::set_blueprint_entities, set_blueprint_tiles, label, blueprint_description, preview_icons, checked with valid_for_write. This works: a placeholder record was overwritten from a string imported into a script inventory.
  • LuaItemStack::import_stack / export_stack and LuaItemCommon::set_blueprint_entities: items only, not library records.
Missing: game.blueprints is read-only, LuaRecord has no import or destroy, and only a player's drag moves an item into the library.

Suggested API (names are only suggestions)

Code: Select all

LuaGameScript::import_blueprint_record(string, index?) -> LuaRecord?   -- adds to the Game blueprints shelf; nil or an error code on a bad string
LuaGameScript::create_blueprint_record{ type = "blueprint" | "blueprint-book" | "deconstruction-planner" | "upgrade-planner", index? } -> LuaRecord
LuaRecord::destroy()                                                     -- removes a Game blueprints record (valid_for_write records only)
Nice to have:
  • the same for a book's contents (LuaRecord::insert_record / import_record into a book record);
  • an event when a Game blueprints record is added, removed or edited, so mods don't have to poll game.blueprints.
Thanks!
Post Reply

Return to “Modding interface requests”