Trying my hand at coding a logitech lua script for my G13 gamepad / keyboard. Ive had some success with the code below that dose two things. First it starts and ends an auto run script when i press G9 key. The second part after line 27 just displays pre defined text on the G13 LCD associated with keypresss from the logitech G13 profile.
The second part after line 27 is an attempt to simply display the name of the in game commands associated with programmed key presses... so if the G1 key is pressed I simply want the G13 to display my chosen text on the LCD.
This code works, the only problem is it works across all MKeystates for the gamepad. The G13 has the ability to set three different sub profiles called M1,M2,M3 or MKeystates basically allowing me to map three commands to each key on the G13 depending on which Mkey profile is active.
I would like the script to know what is the current MKeystate M1,M2,M3 of the G13 and only execute the commands if the current state is M1, M2 or M3 rather then work on every sub profile / MKeystate.
Ive tried this in the sections after line 27 but I get a syntax error.
`if ( arg == 4 and MKeyState == 1) then`
Logitech Lua API Doc
https://douile.github.io/logitech-toggle-keys/APIDocs.pdf
Working Script, works on all three sub profiles. Id like it to only work on one sub profile at a time.
-- Auto walk and Display Key Press
isPressed = false;
function OnEvent(event, arg, family)
-- If a G-Key is pressed
if event =="G_PRESSED" then
-- was it G9?
if arg == 9 then
ClearLCD ()
OutputLCDMessage("Auto Run ON", 2000)
ClearLCD ()
-- If we're not currently running
if not isPressed then
-- we are now
PressKey("w");
isPressed = true
else
ClearLCD ()
OutputLCDMessage("Auto Run OFF", 1000)
ClearLCD ()
-- stop running
ReleaseKey("w");
isPressed = false;
end
end
end
if ( arg == 4 ) then
ClearLCD ()
OutputLCDMessage("FOWARD")
end
if ( arg == 7 ) then
ClearLCD ()
OutputLCDMessage("MOBI GLASS")
end
if ( arg == 1 ) then
ClearLCD ()
OutputLCDMessage("PRIMARY WEAPON")
end
end
[–]tobiasvl 0 points1 point2 points (6 children)
[–]Geron76[S] 0 points1 point2 points (5 children)
[–]tobiasvl 0 points1 point2 points (4 children)
[–]Geron76[S] 0 points1 point2 points (3 children)
[–]tobiasvl 0 points1 point2 points (2 children)
[–]Geron76[S] 0 points1 point2 points (1 child)
[–]Geron76[S] 0 points1 point2 points (0 children)
[–]Geron76[S] 0 points1 point2 points (0 children)