From e93fc3e68cccf15f68a6b83eebc736c4bbd74eef Mon Sep 17 00:00:00 2001 From: Tom Burrows Date: Tue, 1 Oct 2024 01:49:46 +0100 Subject: [PATCH] game.prototypes -> prototypes --- control.lua | 4 ++-- scripts/custom-input.lua | 20 ++++++++++---------- scripts/gui.lua | 6 +++--- scripts/search.lua | 8 ++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/control.lua b/control.lua index db14ae1..5c059f9 100644 --- a/control.lua +++ b/control.lua @@ -56,14 +56,14 @@ local function generate_item_to_entity_table() -- Exception in mineable_properties is we don't want to include entity_name when type == "simple-entity" if item_name is a resource -- This prevents things like rocks showing when searching for stone - local resource_prototypes = game.get_filtered_entity_prototypes({{filter = "type", type = "resource"}}) + local resource_prototypes = prototypes.get_entity_filtered({{filter = "type", type = "resource"}}) local is_resource = {} for _, resource in pairs(resource_prototypes) do is_resource[resource.name] = true end - local prototypes = game.get_filtered_entity_prototypes({}) + local prototypes = prototypes.get_entity_filtered({}) -- Filter out rocks local item_to_entities = {} for _, prototype in pairs(prototypes) do diff --git a/scripts/custom-input.lua b/scripts/custom-input.lua index bd41780..1e3a28f 100644 --- a/scripts/custom-input.lua +++ b/scripts/custom-input.lua @@ -27,19 +27,19 @@ script.on_event("open-search-prototype", end if event.selected_prototype.derived_type == "resource" then -- If we know it is a resource, then ensure we treat it as one first - local products = game.entity_prototypes[name].mineable_properties.products + local products = prototypes.entity[name].mineable_properties.products if products then name = products[1].name type = products[1].type end - elseif game.item_prototypes[name] then + elseif prototypes.item[name] then type = "item" - elseif game.fluid_prototypes[name] then + elseif prototypes.fluid[name] then type = "fluid" - elseif game.virtual_signal_prototypes[name] then + elseif prototypes.virtual_signal[name] then type = "virtual" - elseif game.recipe_prototypes[name] then - local recipe = game.recipe_prototypes[name] + elseif prototypes.recipe[name] then + local recipe = prototypes.recipe[name] local main_product = recipe.main_product if main_product then name = main_product.name @@ -49,8 +49,8 @@ script.on_event("open-search-prototype", name = product.name type = product.type end - elseif game.entity_prototypes[name] then - local entity = game.entity_prototypes[name] + elseif prototypes.entity[name] then + local entity = prototypes.entity[name] local items_to_place_this = entity.items_to_place_this if items_to_place_this and items_to_place_this[1] then name = items_to_place_this[1].name @@ -64,8 +64,8 @@ script.on_event("open-search-prototype", type = products[1].type end end - elseif game.tile_prototypes[name] then - local tile = game.tile_prototypes[name] + elseif prototypes.tile[name] then + local tile = prototypes.tile[name] local items_to_place_this = tile.items_to_place_this if items_to_place_this and items_to_place_this[1] then name = items_to_place_this[1].name diff --git a/scripts/gui.lua b/scripts/gui.lua index 66a9e19..236ef5b 100644 --- a/scripts/gui.lua +++ b/scripts/gui.lua @@ -9,11 +9,11 @@ end local function get_signal_name(signal) if signal.name then if signal.type == "item" then - return game.item_prototypes[signal.name].localised_name + return prototypes.item[signal.name].localised_name elseif signal.type == "fluid" then - return game.fluid_prototypes[signal.name].localised_name + return prototypes.fluid[signal.name].localised_name elseif signal.type == "virtual" then - return game.virtual_signal_prototypes[signal.name].localised_name + return prototypes.virtual_signal[signal.name].localised_name end end end diff --git a/scripts/search.lua b/scripts/search.lua index fbe1eb3..6a4b0b3 100644 --- a/scripts/search.lua +++ b/scripts/search.lua @@ -530,7 +530,7 @@ function Search.blocking_search(force, state, target_item, surface_list, type_li target_entity_name = storage.item_to_entities[target_name] if not target_entity_name then -- Otherwise, check for the item's place_result - local item_prototype = game.item_prototypes[target_name] + local item_prototype = prototypes.item[target_name] if item_prototype and item_prototype.place_result then target_entity_name = item_prototype.place_result.name else @@ -711,7 +711,7 @@ function Search.on_tick() target_entity_name = storage.item_to_entities[target_name] if not target_entity_name then -- Otherwise, check for the item's place_result - local item_prototype = game.item_prototypes[target_name] + local item_prototype = prototypes.item[target_name] if item_prototype and item_prototype.place_result then target_entity_name = item_prototype.place_result.name else @@ -763,7 +763,7 @@ function Search.find_machines(target_item, force, state, player, override_surfac -- Crafting Combinator adds signals for recipes, which players sometimes mistake for items/fluids if target_item.type == "virtual" and not state.signals and (game.active_mods["crafting_combinator"] or game.active_mods["crafting_combinator_xeraph"]) then - local recipe = game.recipe_prototypes[target_name] + local recipe = prototypes.recipe[target_name] if recipe then player.print("[Factory Search] It looks like you selected a recipe from the \"Crafting combinator recipes\" tab. Instead select an item or fluid from a different tab.") return false @@ -781,7 +781,7 @@ function Search.find_machines(target_item, force, state, player, override_surfac add_entity_type(entity_types, ingredient_entities) -- Only add turrets if target is ammo - if target_is_item and game.get_filtered_item_prototypes({{filter = "type", type = "ammo"}})[target_name] then + if target_is_item and prototypes.get_item_filtered({{filter = "type", type = "ammo"}})[target_name] then add_entity_type(entity_types, item_ammo_ingredient_entities) elseif target_is_fluid then add_entity_type(entity_types, fluid_ammo_ingredient_entities)