1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-14 02:34:09 +02:00

Mtn: fix max_wire_distance

This commit is contained in:
Gerkiz 2024-10-27 14:39:18 +01:00
parent 3bb1986035
commit 7ef0fa30e1
2 changed files with 28 additions and 4 deletions

View File

@ -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 }

View File

@ -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