migrate game.item_prototypes for 2.0

This commit is contained in:
Zoryn
2024-10-22 11:14:26 -04:00
parent 22a396d46b
commit fef714c5db
3 changed files with 4 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ local DEFINES_LOW_POWER = defines.entity_status.low_power
---@param map_data MapData ---@param map_data MapData
---@param item_name string ---@param item_name string
function get_stack_size(map_data, item_name) function get_stack_size(map_data, item_name)
return game.item_prototypes[item_name].stack_size return prototypes.item[item_name].stack_size
end end
---@param item_order table<string, int> ---@param item_order table<string, int>
@@ -756,7 +756,7 @@ function set_comb2(map_data, station)
local signals = {} local signals = {}
for item_name, count in pairs(deliveries) do for item_name, count in pairs(deliveries) do
local i = #signals + 1 local i = #signals + 1
local is_fluid = game.item_prototypes[item_name] == nil--NOTE: this is expensive local is_fluid = prototypes.item[item_name] == nil--NOTE: this is expensive
signals[i] = {index = i, signal = {type = is_fluid and "fluid" or "item", name = item_name}, count = sign*count} signals[i] = {index = i, signal = {type = is_fluid and "fluid" or "item", name = item_name}, count = sign*count}
end end
set_combinator_output(map_data, station.entity_comb2, signals) set_combinator_output(map_data, station.entity_comb2, signals)

View File

@@ -135,7 +135,7 @@ local function init_items(manager)
manager.item_order = item_order manager.item_order = item_order
local i = 1 local i = 1
for _, protos in pairs{game.item_prototypes, game.fluid_prototypes} do for _, protos in pairs{prototypes.item, game.fluid_prototypes} do
--- @type (LuaItemPrototype|LuaFluidPrototype)[] --- @type (LuaItemPrototype|LuaFluidPrototype)[]
local all_items = {} local all_items = {}
for _, proto in pairs(protos) do for _, proto in pairs(protos) do

View File

@@ -378,7 +378,7 @@ function set_refueler_combs(map_data, refueler, train)
else else
name = a.name name = a.name
end end
if game.item_prototypes[name] then if prototypes.item[name] then
wagon_signals[1] = {index = 1, signal = {type = "item", name = a.name}, count = 1} wagon_signals[1] = {index = 1, signal = {type = "item", name = a.name}, count = 1}
end end
end end