It is currently November 4th, 2024, 5:48 am

Meters Auto-Adjust to container's height (?)

Get help with creating, editing & fixing problems with skins
RicardoTM
Posts: 436
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Meters Auto-Adjust to container's height (?)

Post by RicardoTM »

Yincognito wrote: October 17th, 2024, 4:46 am
I agree with 'last' being the default, it makes more sense for sure. So you're gonna leave [#CurrentSection] as default as well? That's great, that way [&S:sIx()] will be short enough lol (not saying you'll rename it "sIx" btw, I will :lol:).

I know it is the last occurrence, not the last char. As I mentioned earlier, I got that part clear :lol:

While I'm a bit impatient, I can wait until you publish it :thumbup:
User avatar
Yincognito
Rainmeter Sage
Posts: 8597
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Meters Auto-Adjust to container's height (?)

Post by Yincognito »

RicardoTM wrote: October 17th, 2024, 6:33 am (not saying you'll rename it "sIx" btw, I will :lol:).
Maybe I'll replace the I with any other lowercase vocal, for optimum effect... :sly:
Except u, since I don't think it sux... :lol:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
RicardoTM
Posts: 436
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Meters Auto-Adjust to container's height (?)

Post by RicardoTM »

Yincognito wrote: October 17th, 2024, 6:42 am Maybe I'll replace the I with any other lowercase vocal, for optimum effect... :sly:
Except u, since I don't think it sux... :lol:
You could replace the s instead of the I, with another x for even better impressions. :D
No, it not sux :sly:
User avatar
Yincognito
Rainmeter Sage
Posts: 8597
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Meters Auto-Adjust to container's height (?)

Post by Yincognito »

RicardoTM wrote: October 17th, 2024, 6:33 amWhile I'm a bit impatient, I can wait until you publish it :thumbup:
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.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
RicardoTM
Posts: 436
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Meters Auto-Adjust to container's height (?)

Post by RicardoTM »

Yincognito wrote: October 20th, 2024, 5:32 pm
Hey yin, thank you so much, these are great!

One thing I can suggest btw is using '*' to represent the omissions instead of nil, it is "shorter" eg. SI('*','*','i'). Technically is the same number of characters tho lol

I can confirm the bug, it seems to be caused by the order of the functions, somehow..

By the way, I found another invalid option with this function as well, but I'll mention it on the other thread.
User avatar
Yincognito
Rainmeter Sage
Posts: 8597
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Meters Auto-Adjust to container's height (?)

Post by Yincognito »

RicardoTM wrote: October 20th, 2024, 10:35 pm Hey yin, thank you so much, these are great!

One thing I can suggest btw is using '*' to represent the omissions instead of nil, it is "shorter" eg. SI('*','*','i'). Technically is the same number of characters tho lol

I can confirm the bug, it seems to be caused by the order of the functions, somehow..

By the way, I found another invalid option with this function as well, but I'll mention it on the other thread.
:thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth