Classed key bindings

Classed key bindings

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Classed key bindings

Post by trepan »

Another key binding feature has been added to SVN.
The bindunittype keyword can be used to bind a
keyset to a class of units that you define. You can
also setup the order that will be used to cycle through
the list of unit types that meet your requirements. Here
is an example:

http://trepan.homelinux.net/spring-diffs/advkeys.txt

P.S. That example file is my working test config, so
you'll have to excuse me if it's a little sloppy / incomplete.
The other feature demonstrated at the end of the file is the
positional icon access (using iconpos)
User avatar
LordMatt
Posts: 3393
Joined: 15 May 2005, 04:26

Post by LordMatt »

Please forgive my ignorance, but does that mean we could assign a key combination to select particular kinds of units (e.g. ctrl + alt + r selects all rockos on screen)?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Post by knorke »

// setup the build categories
keysym build_energy b3
keysym build_mex b2
keysym build_builder b1
keysym build_factory b0
I think its like hotkeys for buildings? Like you select a builder, press M and can place a Mex. No need for scrolling through the list.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Post by Argh »

If nothing else, this oughtta be extremely useful to the AI folks. Cool :-)
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Yup, that's a fairly good description. It doesn't just work for builders
making buildings though, the same bindings also apply to factories
making units (ex: selecting an advanced kbot factory and hitting the
stealth binding will send out a spy bot).

Also note that the same mex build binding will produce a Moho mex
for adv builders, and a normal mex for simpler builders.
I think its like hotkeys for buildings? Like you select a builder, press M and can place a Mex
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

How are the units assigned to the keys, e.g. how does Spring know what is a powerplant?
User avatar
FireCrack
Posts: 676
Joined: 19 Jul 2005, 09:33

Post by FireCrack »

KDR_11k wrote:How are the units assigned to the keys, e.g. how does Spring know what is a powerplant?
Things like this in the posted file

Code: Select all

bindbuildtype &build_energy {
  req    totalEnergyOut > 1.0
  sort   not needGeo
  sort   -minWaterDepth
  sort   techLevel
  sort   totalEnergyOut
}
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Post by knorke »

Will you be able to "cycle" through the buildings?
Like Windmill, Tidal, Solar and Adv. Solar are bound to the same hotkey and by pressing "E" (for energy, example) you can switch..
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

You could already cycle through the building types, this
classing system just makes it easier to setup the bindings.

The "sort" property in bindbuildtype determines the order
of the cycling.
Post Reply

Return to “Lua Scripts”