Well, I'm not sure I would say this is "less long and complicated", but:
Skin:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
NumOfVars=9
radio0=0
radio1=0
radio2=0
radio3=0
radio4=0
radio5=0
radio6=0
radio7=0
radio8=0
[MeasureToggle]
Measure=Script
ScriptFile=Test.lua
UpdateDivider=-1
[MeterZero]
Meter=String
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=radio0 = #radio0#
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure MeasureToggle "ToggleVar(0)"]
[MeterOne]
Meter=String
Y=0R
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=radio1 = #radio1#
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure MeasureToggle "ToggleVar(1)"]
Test.lua:
Code: Select all
function Initialize()
numOfVars = SKIN:GetVariable('NumOfVars')
end
function Update()
return numOfVars
end
function ToggleVar(varNum)
currentValue = SKIN:GetVariable('radio'..varNum)
for i = 0, numOfVars -1 do
SKIN:Bang('!SetVariable', 'radio'..i, '0')
end
SKIN:Bang('!SetVariable', 'radio'..varNum, 1 - currentValue)
SKIN:Bang('!UpdateMeter', '*')
SKIN:Bang('!Redraw')
end
test.gif
P.S. None of my business, but I'd be tempted to make the variables "1-based" instead of "0-based", so you have radio1...radio9, NumOfVars is still "9", and you change the loop in the .lua to:
Code: Select all
for i = 1, numOfVars do
SKIN:Bang('!SetVariable', 'radio'..i, '0')
end
Just one less thing to think about, there are 9 variables numbered 1..9 and somehow in this instance that seems more logical than 0...8.
You do not have the required permissions to view the files attached to this post.