ctx.schematics.get
This commit is contained in:
@@ -4,7 +4,7 @@ A schematic is a box of the world saved to a file: its blocks with their states
|
||||
placed again somewhere else. Schematic files end in `.cbsm` and are [MessagePack](https://msgpack.org), see
|
||||
`common/schematic.ts` for their format.
|
||||
|
||||
Exporting, registering and placing are built. Blocks making what their data points to when they're placed
|
||||
Exporting, registering, reading and placing are built. Blocks making what their data points to when they're placed
|
||||
(`import_data`) is planned in `STRUCTURES.md`.
|
||||
|
||||
## Exporting
|
||||
@@ -72,6 +72,19 @@ file's.
|
||||
|
||||
It throws for an id nothing registered, or a placement that isn't one, before anything changes.
|
||||
|
||||
## Reading
|
||||
|
||||
`get` gives a copy of a registered schematic, a file's or one a script registered, with its `id`, or `undefined` for an
|
||||
id nothing registered. It's for looking at what's in one before placing it, like where a room's doorways are when
|
||||
fitting rooms together:
|
||||
|
||||
```ts
|
||||
const room = ctx.schematics.get("copper_tools:room")!;
|
||||
const doorways = room.blocks.filter((block) => room.palette[block.i].id === "copper_tools:doorway");
|
||||
```
|
||||
|
||||
Positions in it are from its lowest corner, before it's turned. Changing the copy doesn't change what `place` puts.
|
||||
|
||||
Until `import_data` is built, a block's exported data goes back in as it is, so a chest placed from a schematic has its
|
||||
items' list in its data and no container.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user