Recipe types from shared scripts and stuff
This commit is contained in:
@@ -257,7 +257,7 @@ export class ModRuntime {
|
||||
const ok = run_guarded(mod, "an extend_player_menu", () => {
|
||||
build({
|
||||
add_slot: (container, slot, options) => {
|
||||
added.push(menu_slot(this.game, mod, player, container, slot, options));
|
||||
added.push(menu_slot(mod, player, container, slot, options));
|
||||
return menu.slots.length + added.length - 1;
|
||||
},
|
||||
}, api);
|
||||
@@ -1007,13 +1007,6 @@ export class ModRuntime {
|
||||
interact,
|
||||
},
|
||||
recipes: {
|
||||
furnace_result: (input) => {
|
||||
const recipe = game().recipes.furnace.get(input);
|
||||
return recipe && { output: { ...recipe.output }, cook_time: recipe.cook_time };
|
||||
},
|
||||
fuel_value: (item) => game().recipes.fuel.get(item) ?? 0,
|
||||
is_fuel: (item) => game().recipes.fuel.has(item),
|
||||
is_smeltable: (item) => game().recipes.furnace.has(item),
|
||||
...recipe_lookup(() => game().recipes),
|
||||
list: (type) => structuredClone(game().recipes.by_type.get(type) ?? []),
|
||||
},
|
||||
@@ -1149,7 +1142,7 @@ export class ModRuntime {
|
||||
menu.open_data = structuredClone(value) ?? null;
|
||||
},
|
||||
add_slot(container, slot, options) {
|
||||
menu.slots.push(menu_slot(game, mod, server_player, container, slot, options));
|
||||
menu.slots.push(menu_slot(mod, server_player, container, slot, options));
|
||||
return menu.slots.length - 1;
|
||||
},
|
||||
add_fluid_slot(handler, tank, options) {
|
||||
@@ -1327,7 +1320,6 @@ export function new_stack(item: ItemStack): EngineItemStack {
|
||||
|
||||
// a menu's slot from what a mod's add_slot got
|
||||
function menu_slot(
|
||||
game: GameServer,
|
||||
mod: string,
|
||||
player: ServerPlayer,
|
||||
container: Container,
|
||||
@@ -1345,11 +1337,7 @@ function menu_slot(
|
||||
const { filter, on_take } = options;
|
||||
const guarded = <T>(what: string, fn: () => T) => run_guarded(mod, what, fn);
|
||||
const added: MenuSlot = { container: engine, index: slot, x: options.x, y: options.y };
|
||||
if (filter === "smeltable") {
|
||||
added.filter = (item) => game.recipes.furnace.has(item.type_id);
|
||||
} else if (filter === "fuel") {
|
||||
added.filter = (item) => game.recipes.fuel.has(item.type_id);
|
||||
} else if (typeof filter === "function") {
|
||||
if (typeof filter === "function") {
|
||||
added.filter = (item) => guarded("a slot filter", () => filter(item_api(item))) === true;
|
||||
}
|
||||
if (options.output_only) added.output = true;
|
||||
|
||||
Reference in New Issue
Block a user