Single module modding
This commit is contained in:
@@ -8,7 +8,7 @@ import { copy_dir, stone_floor, test_game } from "./helpers.ts";
|
||||
|
||||
const SERVER_SCRIPT = `
|
||||
import type { ServerContext } from "cubi/server";
|
||||
export function setup(ctx: ServerContext) {
|
||||
export function server(ctx: ServerContext) {
|
||||
const log = (key: string, value: unknown = 1) => {
|
||||
const all = ctx.storage.get<Record<string, unknown[]>>("log") ?? {};
|
||||
(all[key] ??= []).push(value);
|
||||
@@ -41,7 +41,7 @@ export function setup(ctx: ServerContext) {
|
||||
// a pillar placed upside down while sneaking, like a block whose placement reads sneaking
|
||||
const SHARED_SCRIPT = `
|
||||
import type { SharedContext } from "cubi/shared";
|
||||
export function setup(ctx: SharedContext) {
|
||||
export function shared(ctx: SharedContext) {
|
||||
ctx.components.register_block("testmod:pillar", {
|
||||
state_for_placement(placement) { return { flipped: placement.sneaking ? 1 : 0 }; },
|
||||
});
|
||||
@@ -60,7 +60,7 @@ function test_mods() {
|
||||
name: "Test",
|
||||
version: "1.0.0",
|
||||
dependencies: [{ id: "bworld", version: "*" }],
|
||||
scripts: { server: "scripts/server.ts", shared: "scripts/shared.ts" },
|
||||
main: "scripts/main.ts",
|
||||
});
|
||||
const block = (id: string, extra: Record<string, unknown>) => ({
|
||||
format_version: 1,
|
||||
@@ -82,6 +82,10 @@ function test_mods() {
|
||||
write("items/bow.json", item("testmod:bow", { "testmod:bow": { ticks: 5 } }));
|
||||
Deno.writeTextFileSync(`${mod}/scripts/server.ts`, SERVER_SCRIPT);
|
||||
Deno.writeTextFileSync(`${mod}/scripts/shared.ts`, SHARED_SCRIPT);
|
||||
Deno.writeTextFileSync(
|
||||
`${mod}/scripts/main.ts`,
|
||||
`export { server } from "./server.ts";\nexport { shared } from "./shared.ts";\n`,
|
||||
);
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user