Single module modding

This commit is contained in:
2026-11-14 12:18:41 -03:00
parent 605008f584
commit 313098892e
134 changed files with 919 additions and 924 deletions
+4 -4
View File
@@ -22,7 +22,7 @@ async function load(script: string) {
id: "testmod",
name: "Test",
version: "1.0.0",
scripts: { client: "scripts/client.ts" },
main: "scripts/client.ts",
}),
);
Deno.writeTextFileSync(`${dir}/testmod/scripts/client.ts`, script);
@@ -39,7 +39,7 @@ async function load(script: string) {
Deno.test("hud layers draw in order on the same space, and one that throws is removed", async () => {
await load(`
import type { ClientContext } from "cubi/client";
export function setup(ctx: ClientContext) {
export function client(ctx: ClientContext) {
ctx.hud.register("testmod:bar", { on_render(_g, hud) { hud.left_height += 10; } });
ctx.hud.register("testmod:broken", { on_render() { throw new Error("broken"); } });
const above = {
@@ -75,13 +75,13 @@ Deno.test("hud layers draw in order on the same space, and one that throws is re
Deno.test("hud layers are in the mod's namespace, one to an id", async () => {
const layer = `{ on_render() {} }`;
await assertRejects(
() => load(`export function setup(ctx) { ctx.hud.register("bworld:hotbar", ${layer}); }`),
() => load(`export function client(ctx) { ctx.hud.register("bworld:hotbar", ${layer}); }`),
Error,
`must be in the namespace "testmod"`,
);
await assertRejects(
() =>
load(`export function setup(ctx) {
load(`export function client(ctx) {
ctx.hud.register("testmod:bar", ${layer});
ctx.hud.register("testmod:bar", ${layer});
}`),