It is. Yincognito has created a way to do this. The working example is here https://forum.rainmeter.net/viewtopic.php?f=14&t=36895&start=30#p190373.death.crafter wrote: ↑June 27th, 2021, 4:49 am I may be thrown off a bit here. Is [#*GET*][#*CURRENTSECTION*][#*INDEX*] a way to get the index of a section? I'm pretty sure it is not.
It is currently October 13th, 2024, 7:06 am
[Suggestion] Assigning a number to a meter
-
- Moderator
- Posts: 1318
- Joined: February 16th, 2012, 3:32 am
- Location: Berlin, Germany
Re: [Suggestion] Assigning a number to a meter
-
- Rainmeter Sage
- Posts: 1398
- Joined: April 24th, 2021, 8:13 pm
Re: [Suggestion] Assigning a number to a meter
You did not mention the GET and INDEX variables. Anyway, I already have a thread opened about it.Active Colors wrote: ↑June 27th, 2021, 7:15 am It is. Yincognito has created a way to do this. The working example is here https://forum.rainmeter.net/viewtopic.php?f=14&t=36895&start=30#p190373.
https://forum.rainmeter.net/viewtopic.php?f=14&t=37775
Can you post your example skin in there? I actually changed my skin to the point of no return. I will make another example tho when I am free later.
Thanks,
death.crafter
from the Realm of Death
-
- Moderator
- Posts: 1318
- Joined: February 16th, 2012, 3:32 am
- Location: Berlin, Germany
Re: [Suggestion] Assigning a number to a meter
death.crafter wrote: ↑June 27th, 2021, 7:42 am You did not mention the GET and INDEX variables. Anyway, I already have a thread opened about it.
https://forum.rainmeter.net/viewtopic.php?f=14&t=37775
Can you post your example skin in there? I actually changed my skin to the point of no return. I will make another example tho when I am free later.
Thanks,
death.crafter
Interesting that we decided to post about it simultaneously. I noticed the problem earlier but didn't decide to post it right away. The problem appeared not in the last beta though but several betas earlier (if the causes to our problem are absolutely the same).
This is the full skin:
Skin.ini
Code: Select all
[Rainmeter]
Update=1000
[Variables]
GET=[&Script:SectionIndex('
INDEX=','last','(<x>)')]
CalcThis=([MeterExample[#*GET*][#*CURRENTSECTION*][#*INDEX*]:W]+[MeterSample[#*GET*][#*CURRENTSECTION*][#*INDEX*]:W])
[Script]
Measure=Script
ScriptFile=#@#Scripts\Script.lua
UpdateDivider=-1
DynamicVariables=1
[MeterExample1]
Meter=String
X=5
Y=30
FontFace=Consolas
FontColor=255,255,255
FontSize=12
AntiAlias=1
Text=Example text
[MeterSample1]
Meter=String
X=5
Y=30
FontFace=Consolas
FontColor=255,255,255
FontSize=12
AntiAlias=1
Text=Sample
[MeasureCalc1]
Measure=Calc
Formula=[#CalcThis]
DynamicVariables=1
Code: Select all
function SectionIndex(section, occurrence, formula)
local indexes = {}
for index in section:gmatch('%d+') do table.insert(indexes, index) end
if occurrence == 'first' then occurrence = 1 elseif occurrence == 'last' then occurrence = #indexes end
return tostring(SKIN:ParseFormula(string.gsub(formula, '<x>', tostring(indexes[tonumber(occurrence)] or '0')))) or '0'
end
-
- Rainmeter Sage
- Posts: 8442
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: [Suggestion] Assigning a number to a meter
Yeah, using the GET and INDEX variables was done out of necessity, since using a single CURRENTSECTIONINDEX like variable had drawbacks due to how Rainmeter operates and the tricky nature of #CURRENTSECTION# overall, which is not necessarily related to the last betas.death.crafter wrote: ↑June 27th, 2021, 7:42 am You did not mention the GET and INDEX variables. Anyway, I already have a thread opened about it.
https://forum.rainmeter.net/viewtopic.php?f=14&t=37775
Can you post your example skin in there? I actually changed my skin to the point of no return. I will make another example tho when I am free later.
Thanks,
death.crafter
I would have loved this to be straightforward, but as you can see, it is not, and there aren't many things us users can do about it, unfortunately... which is a pity since otherwise the codes are correct.
-
- Rainmeter Sage
- Posts: 1398
- Joined: April 24th, 2021, 8:13 pm
Re: [Suggestion] Assigning a number to a meter
Actually I was using this thing from a long time. But my lua is something like:Yincognito wrote: ↑June 27th, 2021, 10:44 am Yeah, using the GET and INDEX variables was done out of necessity, since using a single CURRENTSECTIONINDEX like variable had drawbacks due to how Rainmeter operates and the tricky nature of #CURRENTSECTION# overall, which is not necessarily related to the last betas.
I would have loved this to be straightforward, but as you can see, it is not, and there aren't many things us users can do about it, unfortunately... which is a pity since otherwise the codes are correct.
Code: Select all
function Indx(k)
local a=string.gsub(k, '^%D+(%d+)$', '%1')
a = tonumber(a) -- just in case I have to do arithmetic operations
return a
end
from the Realm of Death
-
- Rainmeter Sage
- Posts: 8442
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: [Suggestion] Assigning a number to a meter
Haha, yes, I also like to shorten things up (you could have written just [&S:Idx()], by the way), but I made this from the start with the idea to improve Jeff's version and solve a wide range of instances where one would need such an index once and for all, so it had to be something that everyone would understand - after all, [&Script:SectionIndex()] is not that long.death.crafter wrote: ↑June 27th, 2021, 11:34 am Actually I was using this thing from a long time. But my lua is something like:
Yours has a broad range of use. But I tend to keep things short so I just use [&Str:Indx('[#CURRENTSECTION]')] (I am lazy like hell lol).Code: Select all
function Indx(k) local a=string.gsub(k, '^%D+(%d+)$', '%1') a = tonumber(a) -- just in case I have to do arithmetic operations return a end
Too bad there were these hickups along the way, because otherwise everything should have worked smoothly right from the start and in any circumstance (which was one of my goals, hence the "formula" thing, no dependency on SKIN:GetMeasure() or SKIN:GetMeter(), any occurrence of an index covered, etc).
By the way, I suppose your version doesn't work either if you try to make a custom variable out of it and use it like ActiveColors tried to, right?
-
- Rainmeter Sage
- Posts: 1398
- Joined: April 24th, 2021, 8:13 pm
Re: [Suggestion] Assigning a number to a meter
I guess the issue is comes with a specific case, which is rather hard to diagnose.Yincognito wrote: ↑June 27th, 2021, 11:59 am By the way, I suppose your version doesn't work either if you try to make a custom variable out of it and use it like ActiveColors tried to, right?
But Active Color's case is closer to mine. He tried to use both inlines in a single variable while I use two variables. But we both got errors. So I guess it's an error with [#CURRENTSECTION] and inline lua.
And I noticed another odd thing. If you put a non English alphabet character like ī, in a folder name, anywhere in the path of a lua file, for example root config name as Materiarusuīto, functions like os.clock() don't work at all ,returning null values.
If there isn't a valid reason for this I will make a separate thread.
from the Realm of Death
-
- Rainmeter Sage
- Posts: 8442
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: [Suggestion] Assigning a number to a meter
Unless you refer to issues specific to latest betas, there is no error like that, since plain inline syntax works every time, e.g.:death.crafter wrote: ↑June 27th, 2021, 12:23 pmSo I guess it's an error with [#CURRENTSECTION] and inline lua.
Code: Select all
Formula=([MeterExample[&Script:SectionIndex('[#CURRENTSECTION]','last','(<x>)')]:W]+[MeterSample[&Script:SectionIndex('[#CURRENTSECTION]','last','(<x>)')]:W])
-
- Rainmeter Sage
- Posts: 8442
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: [Suggestion] Assigning a number to a meter
For the record, extracting a current section's index (or of any - altered or not - index occurence of any section, for that matter) is possible now by using a Rainmeter version greater than 4.4.0.3493 (due to the fix mentioned here) and a Lua function similar to the one presented earlier in this thread here.