Save Reactor "Run Lua" code variable to global variable

I have a Reactor that parsecs all of the IR codes that are received from the KiraRxTx plugin. Please tell me how to save the variables created within the Reactor “Run Lua” code to save as a global variable.

For example: test = tonumber(string.sub(pronto_request, 5))

Where “test” would be the saved global variable.

Thank you, Mark

Not much info here. Smacks of an “X-Y problem”, but to the question…

Depends on what you mean by “global”. In Lua, global means global to the execution environment. For Reactor, that means the sandbox in which Luup runs the plugin. It does not mean the entire system. You cannot create a “global” variable in a plugin and have it be accessible to, for example, scene Lua or startup Lua.

Of course, you can set state variables on your KiraRxTx device(s), using luup.variable_set() with an appropriate service ID and name. The values can be retrieved then using luup.variable_get() using the same device ID, service ID and name.

1 Like

Thank you for the quick response! You answered my question perfectly. :+1:
Thank you, Mark

1 Like