The reason I want to do this is because I am trying to light a single key through a script. I want to invoke the script through Logitech lua api. the functionality will act as a feedback response. fx I have create a macro for the G1 button and I want to light that specific button when the macro is active and turn it off when it isn't. My solution is that I have created a C# script that repeatedly looks in a text file. If the text file has written "on" in it, it turns on the LED etc. now I just need a way to update the text file through the logitech Lua API. but it does not seem as I am allowed to write to a file.
I have tried with the following code to write to the text file:
file = io.open("D:\\creative\\programming\\C#\\logi\\test.txt", "w")
file:write("on")
file:close()
but without any luck as I get the error message:
[string "LuaVM"]:35: attempt to index a nil value (global 'io') Line Number:1
------------------------- extra to explain comment ----------------------------
let say that I have actions inside applications in parenthesis and actions without effect in italic: assume it is off to begin: the "->" acts as a g1 press and shows the sate of the toggle after:
-> on -> off
-> (on) -> (on) -> on ========> -> on -> off -> on
because the g1 presses while the loop is running and the application window is focused are queued and will only take effect while outside the application
io
library is absent, so you can not write to a file from Lua code.
But you can execute external program (for example, any exe-file) by creating a macro (of type "shortcut") and invoking it with PlayMacro(macro_name)
from Lua code.
Just write the external program in C#.