Single module modding
This commit is contained in:
@@ -146,12 +146,12 @@ Deno.test("the template's worldgen feature places boulders, the same way every t
|
||||
}
|
||||
assert(boulders >= 1 && boulders <= 8, `${boulders} of 20 chunks got a boulder, expected about 2`);
|
||||
|
||||
// loading the script again (like a client does) gives the same terrain
|
||||
// loading the script again (like a worldgen worker does) gives the same terrain
|
||||
const again = await load_worldgen({
|
||||
mods: ["bworld", "copper_tools"],
|
||||
scripts: ["bworld", "copper_tools"].map((mod) => ({
|
||||
mod,
|
||||
url: new URL(`file://${Deno.realPathSync(dir)}/${mod}/scripts/worldgen.ts`).href,
|
||||
url: new URL(`file://${Deno.realPathSync(dir)}/${mod}/scripts/main.ts`).href,
|
||||
})),
|
||||
ores: worldgen.ores,
|
||||
generator: "bworld:overworld",
|
||||
@@ -202,11 +202,11 @@ Deno.test("mod ores generate into the block they replace", async () => {
|
||||
|
||||
Deno.test("mod storage and block data are saved with the world", async () => {
|
||||
const dir = mods_with_template();
|
||||
// a server script that uses storage and block data
|
||||
// a mod's server phase that uses storage and block data
|
||||
Deno.writeTextFileSync(
|
||||
`${dir}/copper_tools/scripts/server.ts`,
|
||||
`${dir}/copper_tools/scripts/main.ts`,
|
||||
`import type { ServerContext } from "cubi/server";
|
||||
export function setup(ctx: ServerContext) {
|
||||
export function server(ctx: ServerContext) {
|
||||
ctx.components.register_block("copper_tools:announce", {
|
||||
on_create(block) { block.data = { placed_at: ctx.system.current_tick }; },
|
||||
on_interact(block, _params, player) {
|
||||
@@ -237,7 +237,7 @@ export function setup(ctx: ServerContext) {
|
||||
Deno.test("broken mods stop the game from starting", async () => {
|
||||
const dir = mods_with_template();
|
||||
// the block uses a component the script no longer registers
|
||||
Deno.writeTextFileSync(`${dir}/copper_tools/scripts/server.ts`, "export function setup() {}\n");
|
||||
Deno.writeTextFileSync(`${dir}/copper_tools/scripts/main.ts`, "export function server() {}\n");
|
||||
let error = "";
|
||||
try {
|
||||
await test_game(dir);
|
||||
|
||||
Reference in New Issue
Block a user