Jump to content

Lua scripting in logitech software

Keyboy

I'm trying to make a script that allows me to press the button above the scroll wheel on the g303, just to mess around with it a little i decided i would make a script which changed the color to red, but that doesn't even work (syntax error). I was wondering if somebody wanted to help me out?

 

Here is my try, just to try out Lua:

function OnEvent(event, arg)if (event == "MOUSE_BUTTON_PRESSED" and arg == 4) thenx = 1elsex = 0endif x = 1 thenSetBacklightColor(255,0,0);endend

Thanks for the help :)

Thats MY opinion up there, not the ultimate option.

Link to comment
Share on other sites

Link to post
Share on other sites

i have a script i can check this in, but i'll need to un-crash my logitech drivers, i'll be back with an answer.

Link to comment
Share on other sites

Link to post
Share on other sites

-snip-

You tried formatting it? Or is it just the way LTT Forums set it out? 

 

Umm, anyway... about the problem. 

I believe you will have to have it as:

if x == 1 then

instead of what you have for the start of your second IF statement

 

You could try, this will just set x to 1 and set the blacklight without 2 IF statements?:

function OnEvent(event, arg)    if (event == "MOUSE_BUTTON_PRESSED" and arg == 4) then        x = 1        SetBacklightColor(255,0,0);    else        x = 0    endend 

CPU: i5 4670k @ 3.4GHz + Corsair H100i      GPU: Gigabyte GTX 680 SOC (+215 Core|+162 Mem)     SSD: Kingston V300 240GB (OS)      Headset: Logitech G930 

Case: Cosair Vengance C70 (white)                RAM: 16GB TeamGroup Elite Black DDR3 1600MHz       HDD: 1TB WD Blue                              Mouse: Logitech G602

OS: Windows 7 Home Premium                       PSUXFX Core Edition 750w                                                Motherboard: MSI Z97-G45               Keyboard: Logitech G510

Link to comment
Share on other sites

Link to post
Share on other sites

 

You tried formatting it? Or is it just the way LTT Forums set it out? 

 

Umm, anyway... about the problem. 

 

You could try:

function OnEvent(event, arg)    if (event == "MOUSE_BUTTON_PRESSED" and arg == 4) then        x = 1        SetBacklightColor(255,0,0);    else        x = 0    endend 

basicly this, but if you're doing nothing else, the X parameter isnt needed.

 

i dont think the else is required either.

to make the color change back when the key is released, use the MOUSE_BUTTON_RELEASED event.

Link to comment
Share on other sites

Link to post
Share on other sites

-snip-

@Keyboy Edited my answer, not sure if it 100% but could try either. 

CPU: i5 4670k @ 3.4GHz + Corsair H100i      GPU: Gigabyte GTX 680 SOC (+215 Core|+162 Mem)     SSD: Kingston V300 240GB (OS)      Headset: Logitech G930 

Case: Cosair Vengance C70 (white)                RAM: 16GB TeamGroup Elite Black DDR3 1600MHz       HDD: 1TB WD Blue                              Mouse: Logitech G602

OS: Windows 7 Home Premium                       PSUXFX Core Edition 750w                                                Motherboard: MSI Z97-G45               Keyboard: Logitech G510

Link to comment
Share on other sites

Link to post
Share on other sites

-snip-

The X parameter would be needed so that i can do "if x = 1 do etc." and would make it easier to add stuff in the future :)

Thats MY opinion up there, not the ultimate option.

Link to comment
Share on other sites

Link to post
Share on other sites

basicly this, but if you're doing nothing else, the X parameter isnt needed.

 

i dont think the else is required either.

to make the color change back when the key is released, use the MOUSE_BUTTON_RELEASED event.

I guess if he has stuff planned ahead and he wants to use if x = 0 or 1 for simpleness? - But yeah, never actually done any LUA stuff for Logitech software, just in other applications/games. 

CPU: i5 4670k @ 3.4GHz + Corsair H100i      GPU: Gigabyte GTX 680 SOC (+215 Core|+162 Mem)     SSD: Kingston V300 240GB (OS)      Headset: Logitech G930 

Case: Cosair Vengance C70 (white)                RAM: 16GB TeamGroup Elite Black DDR3 1600MHz       HDD: 1TB WD Blue                              Mouse: Logitech G602

OS: Windows 7 Home Premium                       PSUXFX Core Edition 750w                                                Motherboard: MSI Z97-G45               Keyboard: Logitech G510

Link to comment
Share on other sites

Link to post
Share on other sites

@Keyboy Edited my answer, not sure if it 100% but could try either. 

from my experimenting, its best to keep the scripts as simple as possible, i have locked up my pc a few too many times before to even think of overcomplicating things.

EDIT: IF you need a parameter, PLEASE dont call it x, math does that enough for us, name it something you'll remember.

Link to comment
Share on other sites

Link to post
Share on other sites

The X parameter would be needed so that i can do "if x = 1 do etc." and would make it easier to add stuff in the future :)

hahah just what I said above  :lol:

CPU: i5 4670k @ 3.4GHz + Corsair H100i      GPU: Gigabyte GTX 680 SOC (+215 Core|+162 Mem)     SSD: Kingston V300 240GB (OS)      Headset: Logitech G930 

Case: Cosair Vengance C70 (white)                RAM: 16GB TeamGroup Elite Black DDR3 1600MHz       HDD: 1TB WD Blue                              Mouse: Logitech G602

OS: Windows 7 Home Premium                       PSUXFX Core Edition 750w                                                Motherboard: MSI Z97-G45               Keyboard: Logitech G510

Link to comment
Share on other sites

Link to post
Share on other sites

 

-snip-


I know how weird it sounds, but i find code easier to read when it's not formatted. This does not complain about a syntax error, but for some reason the color doesn't change (tried binding it to RMB, didn't work either)

Thats MY opinion up there, not the ultimate option.

Link to comment
Share on other sites

Link to post
Share on other sites

sidenote: you cannot do loops in the scripts, as that will lock up your driver (experience)

Link to comment
Share on other sites

Link to post
Share on other sites

I know how weird it sound, but i find code easier to read when it's not formatted. This does not complain about a syntax error, but for some reason the color doesn't change (tried binding it to RMB, didn't work either)

note that it'll change to red on the first press, and will remain red until the driver is restarted.

Link to comment
Share on other sites

Link to post
Share on other sites

note that it'll change to red on the first press, and will remain red until the driver is restarted.

Didn't turn red at all :/

Thats MY opinion up there, not the ultimate option.

Link to comment
Share on other sites

Link to post
Share on other sites

Didn't turn red at all :/

i'm not sure if lua needs alignment or not, but if it does, that may be your issue.

Link to comment
Share on other sites

Link to post
Share on other sites

i'm not sure if lua needs alignment or not, but if it does, that may be your issue.

What does "alignment" mean?

I'm a skrub i know

Thats MY opinion up there, not the ultimate option.

Link to comment
Share on other sites

Link to post
Share on other sites

Didn't turn red at all :/

I believe that it will only work with some Logitech Products.. well, I think all the keyboards. But only some mice like someone said here only this can be done on the G13.

 

Also, his is different for example he has: 

SetBacklightColor(255, 255, 255, "mouse")

and you have

SetBacklightColor(255, 255, 255,)

Not sure if this is your problem or not. 

CPU: i5 4670k @ 3.4GHz + Corsair H100i      GPU: Gigabyte GTX 680 SOC (+215 Core|+162 Mem)     SSD: Kingston V300 240GB (OS)      Headset: Logitech G930 

Case: Cosair Vengance C70 (white)                RAM: 16GB TeamGroup Elite Black DDR3 1600MHz       HDD: 1TB WD Blue                              Mouse: Logitech G602

OS: Windows 7 Home Premium                       PSUXFX Core Edition 750w                                                Motherboard: MSI Z97-G45               Keyboard: Logitech G510

Link to comment
Share on other sites

Link to post
Share on other sites

What does "alignment" mean?

I'm a skrub i know

We all gotta start somewhere, here is an example:

function()    if x==1 then        SetBacklightColor(255, 0, 0)    endend

Above, this is WITH alignment. 

function()if x==1 thenSetBacklightColor(255, 0, 0,)endend

The example above is WITHOUT alignment.

 

I always align my stuff (it is easier for me to read) but I guess it is different for you. Also, I guess it is good practice to do so. But.... we all have our own way of doing things. 

CPU: i5 4670k @ 3.4GHz + Corsair H100i      GPU: Gigabyte GTX 680 SOC (+215 Core|+162 Mem)     SSD: Kingston V300 240GB (OS)      Headset: Logitech G930 

Case: Cosair Vengance C70 (white)                RAM: 16GB TeamGroup Elite Black DDR3 1600MHz       HDD: 1TB WD Blue                              Mouse: Logitech G602

OS: Windows 7 Home Premium                       PSUXFX Core Edition 750w                                                Motherboard: MSI Z97-G45               Keyboard: Logitech G510

Link to comment
Share on other sites

Link to post
Share on other sites

-snip-

I see, thanks. The one i am using right now is with alignment, but still doesn't work.

Thats MY opinion up there, not the ultimate option.

Link to comment
Share on other sites

Link to post
Share on other sites

I see, thanks. The one i am using right now is with alignment, but still doesn't work.

Oh right okay. It might just be a case of your product not supporting it? Or maybe look at the link I provided before, as well as how that person has done the 

SetBacklightColor

CPU: i5 4670k @ 3.4GHz + Corsair H100i      GPU: Gigabyte GTX 680 SOC (+215 Core|+162 Mem)     SSD: Kingston V300 240GB (OS)      Headset: Logitech G930 

Case: Cosair Vengance C70 (white)                RAM: 16GB TeamGroup Elite Black DDR3 1600MHz       HDD: 1TB WD Blue                              Mouse: Logitech G602

OS: Windows 7 Home Premium                       PSUXFX Core Edition 750w                                                Motherboard: MSI Z97-G45               Keyboard: Logitech G510

Link to comment
Share on other sites

Link to post
Share on other sites

so i read trough the manual, turns out the 4th parameter in the SetBacklightColor function is a thing, but the manual only lists "kb" and "lhc"

 

cant hurt to give "mouse" a try tho.

Link to comment
Share on other sites

Link to post
Share on other sites

 

Oh right okay. It might just be a case of your product not supporting it? Or maybe look at the link I provided before, as well as how that person has done the 

SetBacklightColor

I can adjust the color in the Logitech software. If i can't do it from the script, that surely would be strange. (i have the g303)

Thats MY opinion up there, not the ultimate option.

Link to comment
Share on other sites

Link to post
Share on other sites

-snip-

That must be why it wasn't working. Tried with "mouse" didn't work. Damn :/

Thats MY opinion up there, not the ultimate option.

Link to comment
Share on other sites

Link to post
Share on other sites

That must be why it wasn't working. Tried with "mouse" didn't work. Damn :/

may be that my documentation is outdated, because i'm running an older version of the driver (to keep things from crashing into a bridge)

in the scripting interface, go to help, and click scripting-API, it might be updated to what it needs to be on more recent drivers.

Link to comment
Share on other sites

Link to post
Share on other sites

may be that my documentation is outdated, because i'm running an older version of the driver (to keep things from crashing into a bridge)

in the scripting interface, go to help, and click scripting-API, it might be updated to what it needs to be on more recent drivers.

It isn't different in the newer versions, guess i'll just wait and see.

Thats MY opinion up there, not the ultimate option.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×