Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1407

Bugs & Feature Suggestions • [BUG] Multiple Lua functions calling CURRENTSECTION

$
0
0
I believe this might be a test case that we missed when Brian was kind enough to provide the ability to retrieve the value of CURRENTSECTION from Lua some time ago, or otherwise a very curious syntactical / parsing bug...

[SkinFolder]\@Resources\S.lua:

Code:

-- Returns the string result of the formula (arg[3]) for the desired occurrence (arg[2]) of an index from the desired section (arg[1]) function SectionIndex(...)  local Indexes = {}  for index in (arg[1] or SKIN:GetVariable('CURRENTSECTION')):gmatch('%d+') do    Indexes[#indexes + 1] = index  end  return tostring(SKIN:ParseFormula((arg[3] or 'i'):gsub('i', Indexes[arg[2] or #Indexes] or '0'))) or '0'end-- Returns the resolved or not (arg[3]) string of the desired option (arg[2]) from the desired section (arg[1])function OptionValue(...)  local section = arg[1] or SKIN:GetVariable('CURRENTSECTION')  local functional, visual = SKIN:GetMeasure(section), SKIN:GetMeter(section)  return ((functional or visual) and (functional or visual):GetOption(arg[2] or (functional and 'Measure' or 'Meter'), '', arg[3]) or '')endfunction 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' endfunction 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
[SkinFolder]\SI.ini:

Code:

[Rainmeter]Update=1000AccurateText=1DynamicWindowSize=1BackgroundMode=2SolidColor=47,47,47,255---Measures---[S]Measure=ScriptScriptFile=#@#S.luaUpdateDivider=-1---Meters---[Re7su3lt5]Meter=StringFontColor=255,255,255,255FontFace=ConsolasFontSize=16Padding=5,5,5,5AntiAlias=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=-1DynamicVariables=1
The Section Index = ... part in the Text option from the above meter is producing the incorrect '0' (printing from Lua gives empty CURRENTSECTION):
SI Bad.jpg
On the other hand, precisely the same part in the commented Text option is producing the correct '5' (I only swapped the 2nd and the 3rd lines there):
SI Good.jpg
Bottom line, the SI() function works, just not if it's the last one in the Text option. Paradoxally, the OV() one works even if it's the last one in the same option. Both functions request the value of CURRENTSECTION from Lua, but the SI() one does it in a FOR statement (though it shouldn't be a problem since the control expressions are only evaluated once before the loop starts). It's possible that this is a consequence of a ... variable number of arguments to the Lua functions, maybe Rainmeter is not properly 'tracking' where the CURRENTSECTION value is used in that case - just guessing here.

P.S. For conveniency in deciphering my abbreviations, I included the (equivalent) "long name versions" of these functions at the top of the script (having the same behavior). If you wonder, it's not about the abbreviations or confusing them with the parameters for section variables, I already checked that.

Statistics: Posted by Yincognito — Yesterday, 8:33 pm



Viewing all articles
Browse latest Browse all 1407

Trending Articles