Jeff wrote: ↑February 10th, 2021, 7:47 pm
I feel like at the moment this problem could be solved with Lua, you just need a little bit of
Code: Select all
function PullOption(section, name, key)
if section = 'Meter' then m = SKIN:GetMeter(name)
elseif section = 'Measure' then m = SKIN:GetMeasure(name)
else print("We're both stupid or you did something wrong")
end
return m:GetOption(key, '0')
end
and because Rainmeter STILL doesn't allow for user defined options, you can use Group instead, pull out the Inline Lua and
[&Script:PullOption('Measure', 'TheStringMeasure', 'Group')] (you also have a good advantage with this cause you can use #CurrentSection#)
Excellent point, Jeff!
Using my newly acquired Lua knowledge (had to happen some day, LOL) and taking advantage that the OR operator in Lua can be used to "choose" something else than a FALSE value (or the equivalent NIL value, like the
SKIN:GetMeasure('MeasureName') and
SKIN:GetMeter('MeterName') values when Lua doesn't find the respective sections), your Lua code can be shortened further to a one liner by pasting this into a hypothetical
Script.lua file, created in the
@Resources folder of the current skin:
Code: Select all
function GetOption(section, key)
return (SKIN:GetMeasure(section) or SKIN:GetMeter(section)):GetOption(key, '0')
end
or even an actual one liner:
Code: Select all
function GetOption(section, key) return (SKIN:GetMeasure(section) or SKIN:GetMeter(section)):GetOption(key, '0') end
and used like
[&Script:GetOption('SomeSection','SomeOption')] (careful with spaces after commas in native Rainmeter, got an error when trying out your sample until I removed them), where
[Script] is a simple measure like:
Code: Select all
[Script]
Measure=Script
ScriptFile=#@#Script.lua
UpdateDivider=-1
in the skin.
Indeed, it can be used with the
#CURRENTSECTION# variable (or, as recommended, its
nested syntax) as well and even included in a MeterStyle:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
---Measures---
[Script]
Measure=Script
ScriptFile=#@#Script.lua
UpdateDivider=-1
---Styles---
[TextStyle]
Y=0R
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MouseOverAction=[!Log "#CURRENTSECTION# hovered, AssignedValue = [&Script:GetOption('[#CURRENTSECTION]','AssignedValue')]"]
MouseLeaveAction=[!Log "#CURRENTSECTION# leaved, AssignedValue = [&Script:GetOption('[#CURRENTSECTION]','AssignedValue')]"]
---Meters---
[Meter1]
Meter=String
MeterStyle=TextStyle
AssignedValue=1
Text="#CURRENTSECTION#"
;Text="Meter [&Script:GetOption('[#CURRENTSECTION]','AssignedValue')]"
DynamicVariables=1
[Meter2]
Meter=String
MeterStyle=TextStyle
AssignedValue=2
Text="#CURRENTSECTION#"
;Text="Meter [&Script:GetOption('[#CURRENTSECTION]','AssignedValue')]"
DynamicVariables=1
AssignedValue above is a custom / user option and can be retrieved using Lua, being displayed in the Log when hovering or leaving the meters. There is one problem though, or maybe I'm missing something here: when uncommenting the 2nd Text options and commenting the 1st ones in the meters, the font and its size is reset. Does anyone have a clue as to why that happens? Too much self reference, maybe?