RicardoTM wrote: ↑October 17th, 2024, 6:33 amWhile I'm a bit impatient, I can wait until you publish it
Sorry for the delay, as it really was a one minute job (I already had a personal version of the function using the #CURRENTSECTION#, "last" occurrence and "x" defaults if nil-s were passed as arguments, just not while using a variable number of arguments) - here are both...
Longer names, default values, no variable number of arguments versions of SectionIndex() amd OptionValue(), for reference and clarity:
Code: Select all
function SectionIndex(section, occurrence, formula)
local I = {}; for i in (section or SKIN:GetVariable('CURRENTSECTION')):gmatch('%d+') do I[#I + 1] = i end
return tostring(SKIN:ParseFormula((formula or 'index'):gsub('index', I[occurrence or #I] or '0'))) or '0'
end
function OptionValue(section, option, resolve)
return ((SKIN:GetMeasure(section) or SKIN:GetMeter(section)) and (SKIN:GetMeasure(section) or SKIN:GetMeter(section)):GetOption(option, '', resolve) or '')
end
Short names, default values, variable number of arguments versions of SI() and OV(), for my one liner pleasure:
Code: Select all
function SI(...) local I = {}; for i in (arg[1] or SKIN:GetVariable('CURRENTSECTION')):gmatch('%d+') do I[#I+1] = i end; return tostring(SKIN:ParseFormula((arg[3] or 'i'):gsub('i', I[arg[2] or #I] or '0'))) or '0' end
function OV(...) local s = arg[1] or SKIN:GetVariable('CURRENTSECTION'); local f, v = SKIN:GetMeasure(s), SKIN:GetMeter(s); return ((f or v) and (f or v):GetOption(arg[2] or (f and 'Measure' or 'Meter'), '', arg[3]) or '') end
Test skin:
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=47,47,47,255
---Measures---
[S]
Measure=Script
ScriptFile=#@#Script.lua
UpdateDivider=-1
[Num8ber94]
Measure=Calc
Formula=(7+3)
UpdateDivider=-1
DynamicVariables=1
---Meters---
[Re7su3lt5]
Meter=String
FontColor=255,255,255,255
FontFace=Consolas
FontSize=16
Padding=5,5,5,5
AntiAlias=1
Text=Section Name = #CURRENTSECTION##CRLF#Section Index = [&S:SI()]#CRLF#Option Value = [&S:OV()]
;Text=Section Name = #CURRENTSECTION##CRLF#Option Value = [&S:OV()]#CRLF#Section Index = [&S:SI()]
UpdateDivider=-1
DynamicVariables=1
Preview:
SIOV.jpg
Notes:
- 0 to 3 arguments can be used in both
- in the long version I used 'index' and in the short version I used 'i' instead of the previous '<x>' used in the 3rd aka the formula argument
- one can omit successive arguments e.g. SI('A'), but preceding arguments must be set to nil instead of omitting them e.g. SI(nil,nil,'i')
Bug:
- if you comment the 1st Text line in the meter and uncomment the 2nd Text line, the SI() result will be 0 instead of 5 (can you confirm?)
You do not have the required permissions to view the files attached to this post.