Skip to content

Commit

Permalink
Add a hotkey to select all units that are consuming resources (FAFore…
Browse files Browse the repository at this point in the history
  • Loading branch information
gordenwunderlich authored Sep 5, 2023
1 parent cfd0eae commit 57cd42d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lua/keymap/keyactions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ local keyActionsSelectionQuickSelect = {
['select_all_building_eng_onscreen'] = {
action = 'UI_Lua import("/lua/keymap/misckeyactions.lua").SelectAllBuildingEngineers(true)',
category = 'selection',
},['select_all_resource_consumers'] = {
action = 'UI_Lua import("/lua/keymap/misckeyactions.lua").SelectAllResourceConsumers()',
category = 'selection',
},
['select_all_resource_consumers_onscreen'] = {
action = 'UI_Lua import("/lua/keymap/misckeyactions.lua").SelectAllResourceConsumers(true)',
category = 'selection',
},
['select_all_land_units_onscreen'] = {
action = 'UI_SelectByCategory +inview +excludeengineers MOBILE LAND',
Expand Down
2 changes: 2 additions & 0 deletions lua/keymap/keydescriptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ keyDescriptions = {
['select_all_radars'] = '<LOC key_desc_select_all_radars>Select all radars',
['select_all_building_eng'] = '<LOC key_desc_select_all_building_eng>Select all engineers that are requesting resources',
['select_all_building_eng_onscreen'] = '<LOC key_desc_select_all_building_eng_onscreen>Select all engineers that are requesting resources on screen',
['select_all_resource_consumers'] = '<LOC key_desc_select_all_resource_consumers>Select all units that are requesting resources',
['select_all_resource_consumers_onscreen'] = '<LOC key_desc_select_all_resource_consumers_onscreen>Select all units that are requesting resources on screen',
['decrease_game_speed'] = '<LOC key_desc_0079>Decrease game speed',
['increase_game_speed'] = '<LOC key_desc_0080>Increase game speed',
['reset_game_speed'] = '<LOC key_desc_0081>Reset game speed to 0 (Normal Speed)',
Expand Down
32 changes: 32 additions & 0 deletions lua/keymap/misckeyactions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -618,3 +618,35 @@ SelectAllBuildingEngineers = function(onscreen)

SelectUnits(units)
end


---@param onscreen boolean
SelectAllResourceConsumers = function(onscreen)
-- make sure it is always a boolean
onscreen = onscreen or false

-- select units
UISelectionByCategory("SHOWQUEUE", false, onscreen, false, false)
UISelectionByCategory("SILO", true, onscreen, false, false)
UISelectionByCategory("REPAIR", true, onscreen, false, false)

-- filter them in-place
local units = GetSelectedUnits()
local unitCount = table.getn(units)
local unitSelectedHead = 1
for k = 1, unitCount do
local unit = units[k]
local eco = unit:GetEconData()
if (eco.energyRequested > 0) or (eco.massRequested > 0) then
units[unitSelectedHead] = unit
unitSelectedHead = unitSelectedHead + 1
end
end

-- remove empty entries
for k = unitSelectedHead, unitCount do
units[k] = nil
end

SelectUnits(units)
end

0 comments on commit 57cd42d

Please sign in to comment.