How to: Make new keyboard shortcuts

Need help? This is the right place!
Note, reporting bugs and issues should be in the Tech Support forum!

How to: Make new keyboard shortcuts

Postby Anihilnine » 24 Jul 2014, 15:22

I have just made a new keyboard shortcut to 'select nearest idle air scout'. There was a similar one already but it selected all scouts, and only t1 - ignoring t3.

This post explains how to add it to your own game, and also how to invent new shortcuts.

The only new type of shortcut that can be added is to select a certain type of unit. Other shortcuts can be added but require programming knowledge.

Backup your game.prefs, you have the power to do some damage here, possibly crashing FA, definitely destroying your local settings.
Edit your game.prefs, find the UserKeyActions section.
Add an entry like this:

['Select nearest idle t1/t3 scout'] = {action = 'UI_SelectByCategory +nearest +idle AIR INTELLIGENCE', category = 'Custom Keys', order = 1,},

Now start the game, open the keybinding menu, the new action will be listed under a new category called 'custom keys'. Bind the key and you're done.

To make your own selection actions

The entry has this format:
['action name'] = {action = 'lua', category = 'categoryName', order = 1,},

Replace lua with this:
UI_SelectByCategory [modifiers] [categories]

Modifiers can be left out altogether, or you can add them, seperated by a space. Include the + symbol:
+excludeengineers
+nearest
+idle
+goto
+inview
+add

If nearest is not specified it will select all matching units.
Goto will jump the camera
Inview will limit the selection to onscreen units
Add will add to the current selection instead of replacing it

Categories - supply one or more, seperated by a space. If you want everything use the category ALLUNITS.

You can have use comma to indicate OR. So "MOBILE LAND,MOBILE AIR" would take all units that are (mobile and land) or (mobile and air)
Each unit also gets it's own virtual category of it's BlueprintId. So UI_SelectByCategory "url0101,url0103" selects cybran land scouts and medusa
Useful examples of categories are AIR, LAND, COMMAND, RADAR, MOBILE, STRUCTURE

To work out which categories are relevant, you may need to view the unit blueprints. For example with my scout selection I had to view the T3 Spy Plane blueprint to discover it had an INTELLIGENCE category, but no SCOUT category like the old action was using.

The full list of categories is rather large:
Spoiler: show
ABILITYBUTTON
AEON
AIR
AIRSTAGINGPLATFORM
ANTIAIR
ANTIMISSILE
ANTINAVY
ANTISUB
ARTILLERY
BATTLESHIP
BENIGN
BOMBER
BOT
BUBBLESHIELDSPILLOVERCHECK
BUILTBYAIRTIER2FACTORY
BUILTBYAIRTIER3FACTORY
BUILTBYCOMMANDER
BUILTBYEXPERIMENTALSUB
BUILTBYLANDTIER2FACTORY
BUILTBYLANDTIER3FACTORY
BUILTBYNAVALTIER2FACTORY
BUILTBYNAVALTIER3FACTORY
BUILTBYQUANTUMGATE
BUILTBYTIER1ENGINEER
BUILTBYTIER1FACTORY
BUILTBYTIER2COMMANDER
BUILTBYTIER2ENGINEER
BUILTBYTIER2FACTORY
BUILTBYTIER2SUPPORTFACTORY
BUILTBYTIER3COMMANDER
BUILTBYTIER3ENGINEER
BUILTBYTIER3FACTORY
CANNOTUSEAIRSTAGING
CANTRANSPORTCOMMANDER
CAPTURE
CARRIER
CIVILIAN
CIVILLIAN
COMMAND
CONSTRUCTION
CONSTRUCTIONSORTDOWN
COUNTERINTELLIGENCE
CRUISER
Cybran
CYBRAN
DEFENSE
DEFENSIVEBOAT
DESTROYER
DIRECTFIRE
DRAGBUILD
ECONOMIC
ENERGYPRODUCTION
ENERGYSTORAGE
ENGINEER
ENGINEERSTATION
EXPERIMENTAL
FACTORY
FAVORSWATER
FERRYBEACON
FIELDENGINEER
FRIGATE
GATE
GROUNDATTACK
HIGHALTAIR
HIGHPRIAIR
HOVER
HYDROCARBON
INDIRECTFIRE
INSIGNIFICANTUNIT
INTELLIGENCE
INVULNERABLE
LAND
LIGHTBOAT
MASSEXTRACTION
MASSFABRICATION
MASSPRODUCTION
MASSSTORAGE
MOBILE
MOBILESONAR
NAVAL
NAVALCARRIER
NEEDMOBILEBUILD
NOFORMATION
NUKE
NUKESUB
OMNI
OPERATION
OPTICS
ORBITALSYSTEM
OVERLAYANTIAIR
OVERLAYANTINAVY
OVERLAYCOUNTERINTEL
OVERLAYDEFENSE
OVERLAYDIRECTFIRE
OVERLAYINDIRECTFIRE
OVERLAYMISC
OVERLAYOMNI
OVERLAYRADAR
OVERLAYSONAR
PATROLHELPER
POD
PODSTAGINGPLATFORM
PRODUCTDL
PRODUCTFA
PRODUCTSC1
RADAR
RALLYPOINT
REBUILDER
RECLAIM
RECLAIMABLE
RECLAIMFRIENDLY
REPAIR
RESEARCH
SATELLITE
SCOUT
SELECTABLE
SERAPHIM
SHIELD
SHOWATTACKRETICLE
SHOWQUEUE
SILO
SIZE12
SIZE16
SIZE20
SIZE4
SIZE8
SONAR
SORTCONSTRUCTION
SORTDEFENSE
SORTECONOMY
SORTINTEL
SORTSTRATEGIC
SPECIALHIGHPRI
SPECIALLOWPRI
STATIONASSISTPOD
STRATEGIC
STRUCTURE
SUBCOMMANDER
SUBMERSIBLE
SUPPORTFACTORY
T1SUBMARINE
T2SUBMARINE
TACTICALMISSILEPLATFORM
TANK
TARGETCHASER
TECH1
TECH2
TECH3
TELEPORTBEACON
TRANSPORTATION
TRANSPORTBUILTBYTIER1FACTORY
TRANSPORTBUILTBYTIER2FACTORY
TRANSPORTBUILTBYTIER3FACTORY
TRANSPORTFOCUS
UEF
UNSELECTABLE
UNTARGETABLE
USEBUILDPRESETS
VERIFYMISSILEUI
VISIBLETORECON
WALL


Some real world keyaction examples:
['goto_commander'] = {action = 'UI_SelectByCategory +nearest +goto COMMAND', category = 'selection', order = 49,},
['select_commander'] = {action = 'UI_SelectByCategory +nearest COMMAND', category = 'selection', order = 50,},
['select_engineers'] = {action = 'UI_SelectByCategory ENGINEER', category = 'selection', order = 45,},
['select_all'] = {action = 'UI_SelectByCategory ALLUNITS', category = 'selection', order = 51,},

For all of the real ones used by the game, inside faforever.nxt, open \lua\keymap\keyactions.lua

To make your own (non selection) actions

You can replace the lua so instead of invoking UI_SelectByCategory, just invoke any lua.
For example, this will make it ai_instaBuild mappable:
['Insta build'] = {action = 'ai_InstaBuild', category = 'Custom Keys', order = 1,},

In case you don't know what instaBuild does, if cheats are enabled, everything you try and build will happen instantly, useful for testing things ... like new hotkeys.

There you have it, you can now select the nearest onscreen idle mass fabricator.

I just hope you use this knowledge for peaceful reasons.
Last edited by Anihilnine on 20 Oct 2015, 13:29, edited 4 times in total.
Anihilnine
Moderator
 
Posts: 2098
Joined: 16 Apr 2013, 10:10
Has liked: 241 times
Been liked: 356 times
FAF User Name: Anihilnine

Re: How to: Make new keyboard shortcuts

Postby Poch » 26 Jul 2014, 12:59

Thank you for sharing that's really well explained and very handy :)

I'll take some time to make shortcuts soon i think. I need to look at the categories and play a few game but i'm sure i'll find something usefull ! Like select neared idle air scout ^^
User avatar
Poch
Avatar-of-War
 
Posts: 133
Joined: 14 Feb 2013, 12:39
Has liked: 11 times
Been liked: 47 times
FAF User Name: Poch

Re: How to: Make new keyboard shortcuts

Postby ZeRen » 18 Sep 2014, 12:00

thx for this ;)

I need advise:
['Select T3 idle engis on screen'] = {
order = 4,
action = 'UI_SelectByCategory +inview +idle TECH3 ENGINEER',
category = 'Custom Keys'
},

this should select only T3 engis on screen. but it selecting SCU as well, do you know pls how to do that?
------------------
I dont understand that:
For all of the real ones used by the game, inside faforever.nxt, open \lua\keymap\keyactions.lua

so I sould open faforever.nxt and in that file find \lua\keymap\keyactions.lua ?
Iam confused ( I tried find \lua\keymap\keyactions.lua in PC, but I couldn´t)
------------------
Can you tell me where to find those blueprints?

edit: nevermind I found it :D
User avatar
ZeRen
Evaluator
 
Posts: 517
Joined: 03 Aug 2014, 08:22
Has liked: 145 times
Been liked: 36 times
FAF User Name: ZeRen

Re: How to: Make new keyboard shortcuts

Postby Anihilnine » 18 Sep 2014, 16:02

this should select only T3 engis on screen. but it selecting SCU as well

so faforever.nxt is a found here: C:\ProgramData\FAForever\gamedata\
it is a zip file. copy it and rename it as zip and extract it somewhere.
then from there, open \lua\keymap\keyactions.lua

should select only T3 engis on screen. but it selecting SCU as well

so both engies and scu have the same categories as what you put in, so it is correctly selecting both. You need to find an extra category that engie has that SCU doesn't ... which you do by comparing the blueprints.
UI_SelectByCategory +inview +idle TECH3 ENGINEER BUILTBYTIER3FACTORY
Anihilnine
Moderator
 
Posts: 2098
Joined: 16 Apr 2013, 10:10
Has liked: 241 times
Been liked: 356 times
FAF User Name: Anihilnine

Re: How to: Make new keyboard shortcuts

Postby Anihilnine » 18 Sep 2014, 16:02

p.s. whilst experimenting you can just type the UI_SelectByCategory thing into console ...
Anihilnine
Moderator
 
Posts: 2098
Joined: 16 Apr 2013, 10:10
Has liked: 241 times
Been liked: 356 times
FAF User Name: Anihilnine

Re: How to: Make new keyboard shortcuts

Postby ZeRen » 18 Sep 2014, 20:14

thx

I made some keybind I were missing

Spoiler: show
['Select nearest idle t1/t3 scout'] = {
order = 1,
action = 'UI_SelectByCategory +nearest +idle AIR INTELLIGENCE',
category = 'Custom Keys'
},
['Select T1 idle engis on screen'] = {
order = 2,
action = 'UI_SelectByCategory +inview +idle TECH1 ENGINEER',
category = 'Custom Keys'
},
['Select T2 idle engis on screen'] = {
order = 3,
action = 'UI_SelectByCategory +inview +idle TECH2 ENGINEER',
category = 'Custom Keys'
},
['Select T3 idle engis on screen'] = {
order = 4,
action = 'UI_SelectByCategory +inview +idle BUILTBYTIER3FACTORY TECH3 ENGINEER',
category = 'Custom Keys'
},
['Select T1,T2 engis on screen'] = {
order = 5,
action = 'UI_SelectByCategory +inview BUILTBYTIER2FACTORY ENGINEER',
category = 'Custom Keys'
},
['Select land units on screen'] = {
order = 6,
action = 'UI_SelectByCategory +inview +excludeengineers BUILTBYTIER3FACTORY LAND',
category = 'Custom Keys'
},
['Select scus on screen'] = {
order = 7,
action = 'UI_SelectByCategory +inview +idle SUBCOMMANDER',
category = 'Custom Keys'
},
['Select naval units on screen'] = {
order = 8,
action = 'UI_SelectByCategory +inview +excludeengineers BUILTBYTIER3FACTORY NAVAL',
category = 'Custom Keys'
},
['Select experimentals on screen'] = {
order = 9,
action = 'UI_SelectByCategory +inview EXPERIMENTAL MOBILE',
category = 'Custom Keys'
},
['Select fighters on screen'] = {
order = 10,
action = 'UI_SelectByCategory +inview AIR HIGHALTAIR ANTIAIR',
category = 'Custom Keys'
},
['Select bombers on screen'] = {
order = 11,
action = 'UI_SelectByCategory +inview AIR BOMBER',
category = 'Custom Keys'
},
['Select gunships on screen'] = {
order = 12,
action = 'UI_SelectByCategory +inview AIR GROUNDATTACK',
category = 'Custom Keys'
},
User avatar
ZeRen
Evaluator
 
Posts: 517
Joined: 03 Aug 2014, 08:22
Has liked: 145 times
Been liked: 36 times
FAF User Name: ZeRen

Re: How to: Make new keyboard shortcuts

Postby Anihilnine » 19 Sep 2014, 05:03

That's great
Anihilnine
Moderator
 
Posts: 2098
Joined: 16 Apr 2013, 10:10
Has liked: 241 times
Been liked: 356 times
FAF User Name: Anihilnine

Re: How to: Make new keyboard shortcuts

Postby JeeVeS » 19 Sep 2014, 07:27

This is pretty helpful. Do you know a way to add salvation to the hotbuild key for artillary ("b" for me)? I'd also like to add a key for building t2 and t3 support factories, or maybe a modifier like ctrl-w to cycle threw the available supports.
JeeVeS
Avatar-of-War
 
Posts: 139
Joined: 26 Nov 2012, 06:08
Has liked: 4 times
Been liked: 15 times
FAF User Name: IridiumBLOWS

Re: How to: Make new keyboard shortcuts

Postby ZeRen » 19 Sep 2014, 08:32

JeeVeS wrote:This is pretty helpful. Do you know a way to add salvation to the hotbuild key for artillary ("b" for me)? I'd also like to add a key for building t2 and t3 support factories, or maybe a modifier like ctrl-w to cycle threw the available supports.


I like to have so key for support factories, do this is out of my ability :cry:
User avatar
ZeRen
Evaluator
 
Posts: 517
Joined: 03 Aug 2014, 08:22
Has liked: 145 times
Been liked: 36 times
FAF User Name: ZeRen

Re: How to: Make new keyboard shortcuts

Postby Anihilnine » 19 Sep 2014, 08:36

Ok so all of that sounds good but is a seperate topic - you're talking about modifying hotbuild now. This thread is about adding keyboard shortcuts to select units. The answer to your question is I think a ui modder could do that for you but I don't have time right now sorry.
Anihilnine
Moderator
 
Posts: 2098
Joined: 16 Apr 2013, 10:10
Has liked: 241 times
Been liked: 356 times
FAF User Name: Anihilnine

Next

Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests