New mod: 'AddNearestByCategoryToSelection'

Everything about mods can be found here.

Moderator: Morax

New mod: 'AddNearestByCategoryToSelection'

Postby crispweed » 02 Jan 2017, 17:51

So this is a really minimal mod, just to make it possible to add custom hotkeys for actions like 'add one idle tech one engineer to current selection'.

If you are not already happy with setting up custom hotkey actions, there is another thread you should read about this first.
(Forum software won't let me post a link to this, but thread id is 8230!)
[update: so I can post links now, and the thread I was talking about is here viewtopic.php?f=41&t=8230]

So then I have a bunch of hotkey actions for different unit types, and selection filters, e.g.:

Code: Select all
                ['Select onscreen idle artillery'] = {
                    order = 32,
                    action = 'UI_SelectByCategory +inview +idle MOBILE LAND ARTILLERY',
                    category = 'Selection Matrix'
                },


Now, with this mod, I can also add hot keys like the following:

Code: Select all
                ['AddOne idle artillery'] = {
                    order = 34,
                    action = "UI_Lua import('/mods/AddNearestByCategoryToSelection/lua.lua').AddNearestByCategoryToSelection('+idle MOBILE LAND ARTILLERY')",
                    category = 'Selection Matrix'
                },


Have fun!

Thomas

(Mod posted as attachment, because I couldn't get the mod upload thing to work, in the mod vault..)
Attachments
AddNearestByCategoryToSelection.zip
(1013 Bytes) Downloaded 107 times
Last edited by crispweed on 19 Nov 2017, 17:53, edited 1 time in total.
crispweed
Crusader
 
Posts: 33
Joined: 02 Jan 2017, 17:32
Has liked: 2 times
Been liked: 3 times
FAF User Name: crispweed

Re: New mod: 'AddNearestByCategoryToSelection'

Postby R_Charger » 04 Jan 2017, 20:16

Just to make it clear I think the most useful application for this is to allow incremental selection of the next nearest idle engineer e.g. by creating a hotkey in the UserkeyActions section of your game.prefs file, like this:
['Add one idle T1 engineer'] = {
order = 32,
action = "UI_Lua import('/mods/AddNearestByCategoryToSelection/lua.lua').AddNearestByCategoryToSelection('+idle BUILTBYTIER1FACTORY TECH1 ENGINEER')",
category = 'Custom Keys'
}
Remember the trailing comma if there are additional UserKeyActions in this section.
order can be any number (the order you want them to appear in the F1 menu in-game)
Note the +nearest modifier is not necessary as the nearest unit is always selected and added to the existing selection with each incremental key press.
Remember to back up your game.prefs file before changing anything! There are other examples where it might be useful e.g. selecting the nearest idle bomber (or 2 or 3 with each incremental keypress), or the nearest non-idle fighter or artilllery, or any idle engineer (of any tech level) or tech level 2 or 3 engineers etc.
R_Charger
Avatar-of-War
 
Posts: 141
Joined: 30 Jul 2016, 16:27
Has liked: 9 times
Been liked: 14 times
FAF User Name: Reckless_Charger

Re: New mod: 'AddNearestByCategoryToSelection'

Postby nine2 » 10 Oct 2017, 16:40

This is a cool idea but there is an out of the box hotkey for adding nearest idle engie to current selection
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: New mod: 'AddNearestByCategoryToSelection'

Postby R_Charger » 11 Oct 2017, 08:46

Oh I wasn't aware. So if you press it multiple times it adds multiple engines to the selection like this mod? In any case this works for whatever unit type you like e.g. Artillery, fighters, transports etc as long as you can define the unit category.
R_Charger
Avatar-of-War
 
Posts: 141
Joined: 30 Jul 2016, 16:27
Has liked: 9 times
Been liked: 14 times
FAF User Name: Reckless_Charger

Re: New mod: 'AddNearestByCategoryToSelection'

Postby nine2 » 11 Oct 2017, 12:02

Yep that's all correct.

Ideally we would build up smart select to handle this.

Smart select is a slower, smarter version of selectbycategory that allows excluding categories as well and is used for mainly select all fighters, to exclude t2 and t4 bombers.
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest