How to bind a key to the certain Lua function in the widget?

How to bind a key to the certain Lua function in the widget?

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

Moderator: Moderators

Post Reply
jetbird
Posts: 18
Joined: 21 Oct 2014, 13:19

How to bind a key to the certain Lua function in the widget?

Post by jetbird »

Is it possible?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: How to bind a key to the certain Lua function in the widget?

Post by gajop »

You could always write custom code that would handle key presses and invoke Lua functions.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: How to bind a key to the certain Lua function in the widget?

Post by Silentwings »

Read https://springrts.com/wiki/Lua:Callins and look at addon.KeyPress(key, mods, isRepeat). It's not a binding in the uikeys sense.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: How to bind a key to the certain Lua function in the widget?

Post by FLOZi »

btw you can link directly to each function https://springrts.com/wiki/Lua:Callins#API:KeyPress
jetbird
Posts: 18
Joined: 21 Oct 2014, 13:19

Re: How to bind a key to the certain Lua function in the widget?

Post by jetbird »

Thanks!
User avatar
jamerlan
Balanced Annihilation Developer
Posts: 683
Joined: 20 Oct 2009, 13:04

Re: How to bind a key to the certain Lua function in the widget?

Post by jamerlan »

Also smth like this:

Code: Select all

131	    widgetHandler:AddAction("losradar", toggleLOSRadars)
132	    widgetHandler:AddAction("loscolor", toggleLOSColors)
133	
134	    spSendCommands('unbindkeyset Any+;')
135	    spSendCommands('bind Any+; losradar')
take a look here: http://imolarpg.dyndns.org/trac/balates ... colors.lua
Post Reply

Return to “Lua Scripts”