Keight Posted September 18, 2022 Report Posted September 18, 2022 Hi. The control will not send when I use concatenated variable in ipc.control. cdukey = L_CDU_5 works perfectly but cdukey = "L_CDU_" .. n does not despite ipc.display showing L_CDU_5. function SET(n) Click_L = 0x20000000 -- Left mouse click L_CDU_5 = 69632+358 -- Left CDU 5 Key Command cdukey = "L_CDU_" .. n ipc.control(cdukey, Click_L) ipc.display(cdukey) end SET(5) What am I doing wrong?
John Dowson Posted September 18, 2022 Report Posted September 18, 2022 ipc.control takes the control number (n) as a parameter, as an integer. You are passing a string, Even though the sting holds the name of a local variable which holds a number, it is the string that is passed to the function, not the variable value. This should work: ipc.control(L_CDU_5 , Click_L)
Keight Posted September 18, 2022 Author Report Posted September 18, 2022 4 minutes ago, John Dowson said: This should work: ipc.control(L_CDU_5 , Click_L) yes as I wrote this works but I am trying to set the "5" part of the "L_CDU_5" by variable n.
John Dowson Posted September 18, 2022 Report Posted September 18, 2022 20 minutes ago, Keight said: yes as I wrote this works but I am trying to set the "5" part of the "L_CDU_5" by variable n. But you cannot do this, as cdukey is a string - just because that holds the variable name, it is not that variable. You could try with: ipc.control(_G[cdukey], Click_L) see https://stackoverflow.com/questions/43776809/how-to-use-string-as-variable-name-in-lua, or google further... John 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now