Skip to content

Commit

Permalink
Mtn: fix max_wire_distance
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerkiz committed Oct 27, 2024
1 parent 3bb1986 commit 7ef0fa3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion maps/mountain_fortress_v3/icw/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
30 changes: 27 additions & 3 deletions maps/mountain_fortress_v3/stateful/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7ef0fa3

Please sign in to comment.