Posting a sample code, as FreeRaider asked would definitely be a good idea, however I can say some generalities:
rbriddickk84 wrote:What i want to achieve is this:
- There is a variable in the INI file
...
Eg, let's say, you have the following variable, defined in the [Variables] section of your skin:
You also have to create a Script measure, which will handle the lua code:
Code: Select all
[MeasureLuaScript]
Measure=Script
ScriptFile=#@#Change.lua
rbriddickk84 wrote:What i want to achieve is this:
...
- Get that variable's value in LUA
...
About the lua code you have to know that it has two very important functions, Initialize() and Update(). Initialize() is executed once, immediately after you're refreshing your skin, while Update() is executed on each update cycle of the skin. To get the value of the variable into the lua code, add the following command to the Update() function:
MyVar = tonumber(SKIN:GetVariable('MyVar')). The
SKIN:GetVariable('MyVar')) expression gets the variable, while the tonumber() function converts this gotten value, to a number.
Now you can even process this value:
(add this command after the previous one). This command will add 2 to the gotten variable.
If the variable is changing in the ini file, the lua script will get automatically the changed value (see immediately).
rbriddickk84 wrote:What i want to achieve is this:
...
- Get the changed value in the LUA
Now the last thing would be to transfere the processed variable back to the ini file. This will be done for example by the following command (add this after the previous command):
SKIN:Bang('!SetVariable', 'NewVar', MyVar). See that the value of the MyVar variable will be transferred to the NewVar variable, which can be used into the ini file, eg in the following String meter:
Code: Select all
[MeterVariables]
Meter=STRING
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=#MyVar##CRLF##NewVar#
DynamicVariables=1
Very important here is the
DynamicVariables=1 option. Without this, the string meter can't properly get the variable, changed dynamically by the lua script.
rbriddickk84 wrote:What i want to achieve is this:
...
- Changing the value of the variable in the INI file
Now one more: to see how the dynamic change works, you have to add eg a
LeftMouseUpAction=[!SetVariable MyVar "(#MyVar#+1)"] option to the [MeterVariables] string meter. This way you're dynamically changing the value of the variable and the processed NewVar will follow the change, through the lua script.
The whole codes:
.ini:
Code: Select all
[Rainmeter]
Update=1000
[Variables]
MyVar=24
[MeasureLuaScript]
Measure=Script
ScriptFile=#@#Change.lua
[MeterVariables]
Meter=STRING
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=#MyVar##CRLF##NewVar#
DynamicVariables=1
LeftMouseUpAction=[!SetVariable MyVar "(#MyVar#+1)"]
Change.lua:
Code: Select all
function Initialize()
end
function Update()
MyVar = tonumber(SKIN:GetVariable('MyVar'))
MyVar = MyVar + 2
SKIN:Bang('!SetVariable', 'NewVar', MyVar)
end
Place this script to the @Resources folder.
Please let me know if this answer your question.