ctx.schematics.get
This commit is contained in:
@@ -245,6 +245,21 @@ Deno.test("a schematic is checked when it's registered, and a placement before a
|
||||
assertEquals(t.game.world.get_block_id(0, 100, 0), "cubi:air");
|
||||
});
|
||||
|
||||
Deno.test("get gives a copy of a registered schematic with its id, a file's or a script's", async () => {
|
||||
const t = await place_setup();
|
||||
const hut = t.schematics.get("testmod:hut")!;
|
||||
assertEquals(hut.id, "testmod:hut");
|
||||
assertEquals(hut.size, [2, 2, 1]);
|
||||
assertEquals(hut.palette[hut.blocks.find((block) => block.p.join() === "0,1,0")!.i].id, "bworld:furnace");
|
||||
assertEquals(t.schematics.get("testmod:post")?.id, "testmod:post");
|
||||
assertEquals(t.schematics.get("testmod:nothing"), undefined);
|
||||
|
||||
// changing the copy doesn't change what's placed
|
||||
hut.palette[0].id = "bworld:stone";
|
||||
t.schematics.place("testmod:hut", { position: { x: 10, y: 100, z: 20 } });
|
||||
assertEquals(t.game.world.get_block_id(10, 100, 20), "bworld:oak_planks");
|
||||
});
|
||||
|
||||
Deno.test("a mod's schematics/<name>.cbsm files are registered as <mod id>:<name> before its scripts run", async () => {
|
||||
const t = await place_setup();
|
||||
assertStringIncludes(String(t.game.mods.storage.testmod?.post), "registered twice");
|
||||
|
||||
Reference in New Issue
Block a user