FreeRaider wrote:jsmorley, I have a question:
out of curiosity, in your lua script you use for i = 1, 5 do etc because in your code you call meters with [Meter1], [Meter2], etc , for simplicity.
In a general case, is it possible grab all meters (and to use its numerosity in a "for statement") even if they have literary names (for example: [MeterNow], [MeterTomorrow], [MeterBla], [MeterTemp], etc) ?
Thanks
Nothing built into our interface between Lua and Rainmeter. You would have write some kind of .ini file "parser" that read the entire file, detected the [Sections] and looked for lines starting with Meter= to determine that it's a meter. Then you could get the section names and create handles that you could use with GetOption.
Something like this might help:
https://docs.rainmeter.net/snippets/read-ini/
Be aware though, that Lua can't read external UTF=16 files, which skin .ini files often are. That will make this a limited solution, and not something with reliable general-purpose use. To be honest, probably more trouble than it's worth... It's really better to either use a numbering scheme like I did, or just hard-code the meter names into the Lua in the Initialize() function to get the meter handles you need.
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[MeasureScript]
Measure=Script
ScriptFile=Test.lua
UpdateDivider=-1
[MeterLarry]
Meter=String
Group=X
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Larry
[MeterMoe]
Meter=String
Group=Y
Y=0R
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Moe
[MeterCurlyJoe]
Meter=String
Group=X
Y=0R
FontSize=11
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=CurlyJoe
Code: Select all
function Initialize()
meterArray = {}
meterArray[1] = SKIN:GetMeter('MeterLarry')
meterArray[2] = SKIN:GetMeter('MeterMoe')
meterArray[3] = SKIN:GetMeter('MeterCurlyJoe')
end
function Update()
meterNameArray = {}
meterGroupArray = {}
for i = 1, 3 do
meterNameArray[i] = meterArray[i]:GetName()
meterGroupArray[i] = meterArray[i]:GetOption('Group')
print('Meter '..meterNameArray[i]..' is in Group '..meterGroupArray[i])
end
end
1.jpg
You do not have the required permissions to view the files attached to this post.