From 7ef0fa30e1cd1b28812f693bb842454407ebfe4d Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Sun, 27 Oct 2024 14:39:18 +0100 Subject: [PATCH] Mtn: fix max_wire_distance --- maps/mountain_fortress_v3/icw/functions.lua | 2 +- maps/mountain_fortress_v3/stateful/table.lua | 30 ++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/maps/mountain_fortress_v3/icw/functions.lua b/maps/mountain_fortress_v3/icw/functions.lua index ff87ca046..3640144d5 100644 --- a/maps/mountain_fortress_v3/icw/functions.lua +++ b/maps/mountain_fortress_v3/icw/functions.lua @@ -227,7 +227,7 @@ end local function connect_power_pole(entity, wagon_area_left_top_y) local surface = entity.surface - local max_wire_distance = entity.prototype.max_wire_distance + local max_wire_distance = prototypes.entity[entity.name].get_max_wire_distance() local area = { { entity.position.x - max_wire_distance, entity.position.y - max_wire_distance }, { entity.position.x + max_wire_distance, entity.position.y - 1 } diff --git a/maps/mountain_fortress_v3/stateful/table.lua b/maps/mountain_fortress_v3/stateful/table.lua index df78b59b6..536a7151d 100644 --- a/maps/mountain_fortress_v3/stateful/table.lua +++ b/maps/mountain_fortress_v3/stateful/table.lua @@ -471,19 +471,43 @@ end local function get_item_produced_count(_, item_name) local force = game.forces.player + local loco_surface = Public.get('loco_surface') + local production = force.get_item_production_statistics('nauvis').input_counts[item_name] if not production then return false end - return production + if not loco_surface or not loco_surface.valid then + return production + end + + local loco_production = force.get_item_production_statistics(loco_surface.name).input_counts[item_name] + if not loco_production then + return production + end + + + return production + loco_production end -local function get_entity_mined_count(event, item_name) +local function get_entity_mined_count(_, item_name) local force = game.forces.player local count = 0 - for name, entity_count in pairs(force.get_entity_build_count_statistics(event.surface).output_counts) do + for name, entity_count in pairs(force.get_entity_build_count_statistics('nauvis').output_counts) do + if name:find(item_name) then + count = count + entity_count + end + end + + local loco_surface = Public.get('loco_surface') + + if not loco_surface or not loco_surface.valid then + return count + end + + for name, entity_count in pairs(force.get_entity_build_count_statistics(loco_surface.name).output_counts) do if name:find(item_name) then count = count + entity_count end