Skip to content

Commit

Permalink
game.prototypes -> prototypes
Browse files Browse the repository at this point in the history
  • Loading branch information
tburrows13 committed Oct 1, 2024
1 parent 7ef4d67 commit e93fc3e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions scripts/custom-input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions scripts/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions scripts/search.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit e93fc3e

Please sign in to comment.