Export schematics
This commit is contained in:
@@ -530,6 +530,24 @@ export class ModRuntime {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// the tile data of the block at x y z for a schematic: what the first of its components with export_data that
|
||||
// returns something gives, or else a copy of its data
|
||||
export_block_data(x: number, y: number, z: number, id: string): unknown {
|
||||
const components = this.components_with(id, "export_data");
|
||||
if (components.length > 0) {
|
||||
const block = this.block_ref(x, y, z, id);
|
||||
for (const { mod, id: component_id, component, params } of components) {
|
||||
const data = run_guarded(
|
||||
mod,
|
||||
`${component_id} export_data`,
|
||||
() => component.export_data!(block, params),
|
||||
);
|
||||
if (data !== undefined) return structuredClone(data);
|
||||
}
|
||||
}
|
||||
return structuredClone(this.game.world.get_tile(x, y, z)?.mod_data);
|
||||
}
|
||||
|
||||
// the block at x y z was told the one at from changed, and its rules have had their say: its components'
|
||||
// on_neighbor_change
|
||||
#neighbor_changed(x: number, y: number, z: number, from: Position) {
|
||||
@@ -1041,6 +1059,9 @@ export class ModRuntime {
|
||||
},
|
||||
delete: (id) => game().delete_container(id),
|
||||
},
|
||||
schematics: {
|
||||
export: (from, to) => game().export_schematic(from, to),
|
||||
},
|
||||
menus: {
|
||||
extend_player_menu: (build) => {
|
||||
register.running("player menu slot");
|
||||
|
||||
Reference in New Issue
Block a user