ctx.recipes.list api on shared side

This commit is contained in:
2026-10-30 23:17:54 -03:00
parent 4717e45a9a
commit 43aa6b2551
5 changed files with 41 additions and 3 deletions
+2 -1
View File
@@ -237,7 +237,7 @@ export function add_recipe(recipes: RecipeBook, recipe: RecipeJson) {
// ctx.recipes for shared scripts, the same on the server and every client: a recipe registered there is in the book
// on every side without being sent, like one from the mod's recipes/. checked like a data file's. fail throws, as the
// side's error for the mod
// side's error for the mod. list reads the book as it is, so a script sees the recipes of the ones before it
export function shared_recipes_api(
recipes: () => RecipeBook,
setting_up: () => boolean,
@@ -255,5 +255,6 @@ export function shared_recipes_api(
fail((e as Error).message);
}
},
list: (type) => structuredClone(type ? recipes().all.filter((recipe) => recipe.type === type) : recipes().all),
};
}