Tags for smithing recipes

This commit is contained in:
2026-11-13 20:19:37 -03:00
parent 51b5d148bd
commit d48fa8cca5
7 changed files with 130 additions and 47 deletions
+19
View File
@@ -302,6 +302,25 @@ export async function load_as_player(sources: string) {
}
}
// the base game, and a mod after it with these recipes
export function recipes_mod(recipes: Record<string, unknown>) {
const dir = Deno.makeTempDirSync({ prefix: "bworld_recipes_" });
copy_dir("mods/bworld", `${dir}/bworld`);
const write = (path: string, json: unknown) => {
Deno.mkdirSync(`${dir}/kiln/${path.split("/").slice(0, -1).join("/")}`, { recursive: true });
Deno.writeTextFileSync(`${dir}/kiln/${path}`, JSON.stringify(json));
};
write("manifest.json", {
format_version: 1,
id: "kiln",
name: "Kiln",
version: "1.0.0",
dependencies: [{ id: "bworld", version: "*" }],
});
for (const [name, recipe] of Object.entries(recipes)) write(`recipes/${name}.json`, { format_version: 1, recipe });
return dir;
}
export function copy_dir(from: string, to: string) {
if (Deno.statSync(from).isDirectory) {
Deno.mkdirSync(to, { recursive: true });