Some illumination on the previous post.
There are no parameters allowed on the Initialize() or Update() functions in the Rainmeter integration with Lua. Initialize() is just executed automatically, with no parameters, when a Script measure is first set up on the load / refresh of the skin. Update() is just executed automatically, with no parameters, on each update of the Script measure.
Just defining a measure option like that MyVariable=1 on the Script measure does not in and of itself make that value a variable, or in any other way visible to the Lua.
Options on, and values for, measures can be retrieved by a two step process:
1) Create a "measure object" linking the measure to Lua. This is done with the SKIN:GetMeasure() command.
myMeasure = SKIN:GetMeasure('MeasureName')
That will create a measure object called "myMeasure", that is linked to the measure "MeasureName" in the skin. Think of it as a "pointer" to the measure in the skin.
This will normally be done in the Initialize() function of the Lua script file, since it only needs to be done once when the skin is loaded or refreshed, and not on every update of the skin or Script measure.
2) Get the value you want from the measure using that measure object.
This is done with various
Measure Object commands. To get the value of an option on a measure you might use:
Number Value:
myMeasureValue = myMeasure:GetOption('MyOption')
String Value:
myMeasureValue = myMeasure:GetStringOption('MyOption')
That will return the current value of the MyOption option on the measure you created the measure object link to with the myMeasure object.
The SELF: object is a special kind of measure object, that is automatically linked to the Script measure that called the Lua script in the skin . This behaves exactly the same as the SKIN: object, with the exception that you don't first have to create the link to the desired measure, as in step 1) above. That is already done.
So to get the current value of the MyOption option on the Script measure calling the Lua, you could use:
Number Value:
myMeasureValue = SELF:GetOption('MyOption')
String Value:
myMeasureValue = SELF:GetStringOption('MyOption')
The advantage to using SELF to get Options from the Script measure are two:
First, you don't need the specific GetMeasure() command in the Initialize() function. The SELF: object is automatically created, and linked to the Script measure in the skin calling the Lua function.
Second, you could use the same code with a single option defined differently when called by multiple Script measures in your skin. Since SELF: is automatically linked to the Script measure calling the Lua function, the GetOption() GetStringOption() commands will automatically use the value of the option from the calling Script measure.