Skip to content

Commit e246f64

Browse files
committed
Minor renamings
1 parent 5c25619 commit e246f64

4 files changed

Lines changed: 45 additions & 46 deletions

File tree

control.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,8 @@ require "scripts.remote"
9595
---@field resource_count? number
9696
---@field distance? number
9797

98-
---@alias CategorisedSurfaceData EntityGroup[]
99-
10098
---@alias SurfaceDataCategoryName "consumers"|"producers"|"storage"|"logistics"|"modules"|"requesters"|"ground_items"|"entities"|"signals"|"map_tags"
101-
---@alias SurfaceData table<SurfaceDataCategoryName, CategorisedSurfaceData>
99+
---@alias SurfaceData table<SurfaceDataCategoryName, EntityGroup[]>
102100

103101
---@alias SurfaceStatisticsCategoryName "consumers_count"|"producers_count"|"item_count"|"fluid_count"|"module_count"|"entity_count"|"resource_count"|"ground_count"|"request_count"|"signal_count"|"tag_count"
104102
---@alias SurfaceStatistics table <SurfaceStatisticsCategoryName, number>

locale/en/FactorySearch.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ fs-highlight-duration=Number of seconds that highlight boxes and arrows exist fo
2727
fs-non-blocking-search-on=On
2828
fs-non-blocking-search-multiplayer=Multiplayer only
2929
fs-non-blocking-search-off=Off
30-
fs-sort-results-by-name=Entity name
30+
fs-sort-results-by-name=Name
3131
fs-sort-results-by-distance=Distance from player
32-
fs-sort-results-by-count=Item/fluid count
32+
fs-sort-results-by-count=Count
3333
3434
[search-gui]
3535
keep-open=Keep open

scripts/search-gui.lua

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ local function get_signal_name(signal)
1515
end
1616

1717
---@param surface_name string
18-
---@param surface_data CategorisedSurfaceData
18+
---@param entity_groups EntityGroup[]
1919
---@return GuiElemDef[]
20-
function SearchGui.build_surface_results(surface_name, surface_data)
20+
function SearchGui.build_surface_category_results(surface_name, entity_groups)
2121
local gui_elements = {}
22-
for _, group in pairs(surface_data) do
22+
for _, group in pairs(entity_groups) do
2323
local entity_name = group.entity_name
2424
local distance_info = {""}
2525
if group.distance then
@@ -241,61 +241,61 @@ function SearchGui.build_results(data, statistics, frame, check_result_found, in
241241
type = "table",
242242
column_count = 10,
243243
style = "slot_table", -- padding = 0, TODO 2.0
244-
children = SearchGui.build_surface_results(surface_name, surface_data.consumers)
244+
children = SearchGui.build_surface_category_results(surface_name, surface_data.consumers)
245245
},
246246
{
247247
type = "table",
248248
column_count = 10,
249249
style = "slot_table",
250-
children = SearchGui.build_surface_results(surface_name, surface_data.producers)
250+
children = SearchGui.build_surface_category_results(surface_name, surface_data.producers)
251251
},
252252
{
253253
type = "table",
254254
column_count = 10,
255255
style = "slot_table",
256-
children = SearchGui.build_surface_results(surface_name, surface_data.storage)
256+
children = SearchGui.build_surface_category_results(surface_name, surface_data.storage)
257257
},
258258
{
259259
type = "table",
260260
column_count = 10,
261261
style = "slot_table",
262-
children = SearchGui.build_surface_results(surface_name, surface_data.logistics)
262+
children = SearchGui.build_surface_category_results(surface_name, surface_data.logistics)
263263
},
264264
{
265265
type = "table",
266266
column_count = 10,
267267
style = "slot_table",
268-
children = SearchGui.build_surface_results(surface_name, surface_data.modules)
268+
children = SearchGui.build_surface_category_results(surface_name, surface_data.modules)
269269
},
270270
{
271271
type = "table",
272272
column_count = 10,
273273
style = "slot_table",
274-
children = SearchGui.build_surface_results(surface_name, surface_data.entities)
274+
children = SearchGui.build_surface_category_results(surface_name, surface_data.entities)
275275
},
276276
{
277277
type = "table",
278278
column_count = 10,
279279
style = "slot_table",
280-
children = SearchGui.build_surface_results(surface_name, surface_data.ground_items)
280+
children = SearchGui.build_surface_category_results(surface_name, surface_data.ground_items)
281281
},
282282
{
283283
type = "table",
284284
column_count = 10,
285285
style = "slot_table",
286-
children = SearchGui.build_surface_results(surface_name, surface_data.requesters)
286+
children = SearchGui.build_surface_category_results(surface_name, surface_data.requesters)
287287
},
288288
{
289289
type = "table",
290290
column_count = 10,
291291
style = "slot_table",
292-
children = SearchGui.build_surface_results(surface_name, surface_data.signals)
292+
children = SearchGui.build_surface_category_results(surface_name, surface_data.signals)
293293
},
294294
{
295295
type = "table",
296296
column_count = 10,
297297
style = "slot_table",
298-
children = SearchGui.build_surface_results(surface_name, surface_data.map_tags)
298+
children = SearchGui.build_surface_category_results(surface_name, surface_data.map_tags)
299299
},
300300
}
301301
}

scripts/search-results.lua

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ local SearchResults = {}
33
local group_gap_size = 20
44

55
---@param entity LuaEntity
6-
---@param surface_data CategorisedSurfaceData
6+
---@param entity_groups EntityGroup[]
77
---@return EntityGroup
8-
function SearchResults.add_entity(entity, surface_data)
8+
function SearchResults.add_entity(entity, entity_groups)
99
-- Group entities
1010
-- Group contains count, avg_position, selection_box, entity_name, selection_boxes
1111
local entity_name = entity.name
1212
local entity_position = entity.position
1313
local entity_selection_box = entity.selection_box
1414
---@type EntityGroup?
1515
local assigned_group
16-
for _, group in pairs(surface_data) do
16+
for _, group in pairs(entity_groups) do
1717
if entity_name == group.entity_name and math2d.bounding_box.collides_with(entity_selection_box, group.selection_box) then
1818
-- Add entity to group
1919
assigned_group = group
@@ -57,18 +57,18 @@ function SearchResults.add_entity(entity, surface_data)
5757
selection_boxes = {[1] = entity.selection_box},
5858
localised_name = entity.localised_name,
5959
}
60-
table.insert(surface_data, assigned_group)
60+
table.insert(entity_groups, assigned_group)
6161
end
6262
return assigned_group
6363
end
6464

6565
local add_entity = SearchResults.add_entity
6666

6767
---@param entity LuaEntity
68-
---@param surface_data CategorisedSurfaceData
68+
---@param entity_groups EntityGroup[]
6969
---@param recipe LuaRecipe|LuaRecipePrototype
70-
function SearchResults.add_entity_product(entity, surface_data, recipe)
71-
local group = add_entity(entity, surface_data)
70+
function SearchResults.add_entity_product(entity, entity_groups, recipe)
71+
local group = add_entity(entity, entity_groups)
7272
local group_recipe_list = group.recipe_list or {}
7373
recipe_name_info = group_recipe_list[recipe.name] or {localised_name = recipe.localised_name, count = 0}
7474
recipe_name_info.count = recipe_name_info.count + 1
@@ -77,70 +77,71 @@ function SearchResults.add_entity_product(entity, surface_data, recipe)
7777
end
7878

7979
---@param entity LuaEntity
80-
---@param surface_data CategorisedSurfaceData
80+
---@param entity_groups EntityGroup[]
8181
---@param item_count number
82-
function SearchResults.add_entity_storage(entity, surface_data, item_count)
83-
local group = add_entity(entity, surface_data)
82+
function SearchResults.add_entity_storage(entity, entity_groups, item_count)
83+
local group = add_entity(entity, entity_groups)
8484
local group_item_count = group.item_count or 0
8585
group.item_count = group_item_count + item_count
8686
end
8787

8888
---@param entity LuaEntity
89-
---@param surface_data CategorisedSurfaceData
89+
---@param entity_groups EntityGroup[]
9090
---@param fluid_count number
91-
function SearchResults.add_entity_storage_fluid(entity, surface_data, fluid_count)
92-
local group = add_entity(entity, surface_data)
91+
function SearchResults.add_entity_storage_fluid(entity, entity_groups, fluid_count)
92+
local group = add_entity(entity, entity_groups)
9393
local group_fluid_count = group.fluid_count or 0
9494
group.fluid_count = group_fluid_count + fluid_count
9595
end
9696

9797
---@param entity LuaEntity
98-
---@param surface_data CategorisedSurfaceData
98+
---@param entity_groups EntityGroup[]
9999
---@param module_count number
100-
function SearchResults.add_entity_module(entity, surface_data, module_count)
101-
local group = add_entity(entity, surface_data)
100+
function SearchResults.add_entity_module(entity, entity_groups, module_count)
101+
local group = add_entity(entity, entity_groups)
102102
local group_module_count = group.module_count or 0
103103
group.module_count = group_module_count + module_count
104104
end
105105

106106
---@param entity LuaEntity
107-
---@param surface_data CategorisedSurfaceData
107+
---@param entity_groups EntityGroup[]
108108
---@param request_count number
109-
function SearchResults.add_entity_request(entity, surface_data, request_count)
110-
local group = add_entity(entity, surface_data)
109+
function SearchResults.add_entity_request(entity, entity_groups, request_count)
110+
local group = add_entity(entity, entity_groups)
111111
local group_request_count = group.request_count or 0
112112
group.request_count = group_request_count + request_count
113113
end
114114

115115
---@param entity LuaEntity
116-
---@param surface_data CategorisedSurfaceData
116+
---@param entity_groups EntityGroup[]
117117
---@param signal_count number
118-
function SearchResults.add_entity_signal(entity, surface_data, signal_count)
119-
local group = add_entity(entity, surface_data)
118+
function SearchResults.add_entity_signal(entity, entity_groups, signal_count)
119+
local group = add_entity(entity, entity_groups)
120120
local group_signal_count = group.signal_count or 0
121121
group.signal_count = group_signal_count + signal_count
122122
end
123123

124124
---@param entity LuaEntity
125-
---@param surface_data CategorisedSurfaceData
125+
---@param entity_groups EntityGroup[]
126126
---@return number
127-
function SearchResults.add_entity_resource(entity, surface_data)
127+
function SearchResults.add_entity_resource(entity, entity_groups)
128128
local resource_count
129129
if entity.initial_amount then
130130
resource_count = entity.amount / 3000 -- Calculate yield from amount
131131
else
132132
resource_count = entity.amount
133133
end
134134

135-
local group = add_entity(entity, surface_data)
135+
local group = add_entity(entity, entity_groups)
136136
local group_resource_count = group.resource_count or 0
137137
group.resource_count = group_resource_count + resource_count
138138
return resource_count
139139
end
140140

141141
---@param tag LuaCustomChartTag
142-
---@param surface_data CategorisedSurfaceData
143-
function SearchResults.add_tag(tag, surface_data)
142+
---@param entity_groups EntityGroup[]
143+
function SearchResults.add_tag(tag, entity_groups)
144+
-- An alternative to add_entity*, for map tags
144145
-- Tag groups always have size 1
145146
local tag_position = tag.position
146147
local tag_box_size = 8
@@ -168,7 +169,7 @@ function SearchResults.add_tag(tag, surface_data)
168169
},
169170
localised_name = localised_name,
170171
}
171-
table.insert(surface_data, group)
172+
table.insert(entity_groups, group)
172173
end
173174

174175
---@param category SurfaceStatisticsCategoryName

0 commit comments

Comments
 (0)