I'm trying to create a UI mod where I press a certain key and it selects all the idle engineers currently on screen. I have zero experience modding this game and nil experience with LUA, and this was what I could come up with:
- Code: Select all
UISelectionByCategory("ENGINEER", false, true, true, true) -- select the engineer on screen closest to the mouse
Ui_EXpandCurrentSelection() -- select all the engineers on screen
UI_MakeSelectionSet("temp") -- name this selection
local unitlist = {}
for index, unit in selectionSets["temp"] do -- for every engineer...
if unit:IsIdle() then -- if it is idle....
table.insert(unitlist,unit) -- save it in a new list
end
end
AddSelectionSet("temp", unitlist) -- Renew the selection with this new unit list
ApplySelectionSet("temp") -- Make this the active selection
-- SelectUnits(unitlist) Or should I use this function?
Now, my question is: Would this work? And in which function would I have to put it to make it activate by a hotkey? Is there also an easy way to make this hotkey configurable in the controls menu?
Lastly: My first idea was that I could drag a selection box while holding a certain key and that it would then only select the idle engineers, but this seems way harder to do. Any help with this maybe?
Thanks for the help!
-John
BTW: Is this the appropriate forum for this?