It is currently November 4th, 2024, 6:00 am

Min/Max Lua script problem

Get help with creating, editing & fixing problems with skins
Steve_E
Posts: 5
Joined: May 23rd, 2023, 9:53 am

Re: Min/Max Lua script problem

Post by Steve_E »

Yincognito wrote: May 24th, 2023, 11:45 pm If you still want to get out of your depth, but this time in the Rainmeter native code instead of Lua, here's the no script version, just for fun:
Oh, I really do not want to get out of my depth! :uhuh: :D

But, wow, OK, nice to know that it is possible to code the action inside Rainmeter without calling a Lua script.

While the Lua script that you kindly provided is working like a charm, if I also wanted to return the Min value in the code you provided above, would I just change 'Max' to 'Min' in this line?

Code: Select all

Substitute="\s+":"","(.)$":"\1,",",+":",","(#V#{129,256})":"(\1)","(#V#{65,128})":"(\1)","(#V#{33,64})":"(\1)","(#V#{17,32})":"(\1)","(#V#{9,16})":"(\1)","(#V#{5,8})":"(\1)","(#V#{3,4})":"(\1)","(#V#{2,2})":"(\1)","(,)([)]+)":"\2\1","([(])":"Max\1",",$":""
There is much to learn regarding the Rainmeter coding, and while I have read through much of the documentation, there appears to be much more to it than I initially grasped!
User avatar
Yincognito
Rainmeter Sage
Posts: 8597
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Min/Max Lua script problem

Post by Yincognito »

Steve_E wrote: May 25th, 2023, 1:41 am Oh, I really do not want to get out of my depth! :uhuh: :D
Yeah, figured out this much, I was just joking, but you already know that... :D
Steve_E wrote: May 25th, 2023, 1:41 am While the Lua script that you kindly provided is working like a charm, if I also wanted to return the Min value in the code you provided above, would I just change 'Max' to 'Min' in this line?

Code: Select all

Substitute="\s+":"","(.)$":"\1,",",+":",","(#V#{129,256})":"(\1)","(#V#{65,128})":"(\1)","(#V#{33,64})":"(\1)","(#V#{17,32})":"(\1)","(#V#{9,16})":"(\1)","(#V#{5,8})":"(\1)","(#V#{3,4})":"(\1)","(#V#{2,2})":"(\1)","(,)([)]+)":"\2\1","([(])":"Max\1",",$":""
Yep, that's all it takes... if you want to replace the Max value with the Min one. If you want to add such a value to your skin, it's just as simple, you have to duplicate via copy-paste the [MaxFormula] and [Max] combo of measures to another set that you can obviously name accordingly, e.g. [MinFormula] and [Min], and operate the edit in the substitute you mentioned, but in the new set.

Basically, this code will work with minor changes for every comma separated list of positive / negative integer / fractional values in a string (in your case, the [MeasureEcowittHistory] one). The only thing I didn't do was add more "(#V#{129,256})":"(\1)",-like parts before that occurrence, in the way I described in the other thread, and that was only because I thought the user should be able to do it easily, considering the obvious progression as slight adjustments to a decreasing list of powers of 2 for the regex {quantifiers} (i.e. how many times the #V# expression is repeated).

All in all, the principle is simple: the original string list is modified by adding brackets and stuff to groups of X values, where X is represented by the powers of 2 and leftovers progression mentioned above. The progression is from larger groups to smaller ones in order to keep the contents between the brackets unchanged and be able to grab the rest of the (smaller) groups properly using the same #V# base pattern (stored as a variable at the start of the code). In a way, it's like formatting a datetime string, except it has more steps. This formatted string from [MaxFormula] is converted to a numerical formula in [Max] and the job is done. That's all there is to it. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Steve_E
Posts: 5
Joined: May 23rd, 2023, 9:53 am

Re: Min/Max Lua script problem

Post by Steve_E »

Yincognito wrote: May 25th, 2023, 11:38 am That's all there is to it. ;-)
O.O :? :o

lol - that was completely over my head :???:
User avatar
Yincognito
Rainmeter Sage
Posts: 8597
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Min/Max Lua script problem

Post by Yincognito »

Steve_E wrote: May 25th, 2023, 12:24 pm O.O :? :o

lol - that was completely over my head :???:
Really?! :jawdrop
I thought I was making things simpler to understand... :???:

But ok, if you like a real life example, if't like a bunch of naked people that you need to dress up for some event. You split them in groups so the clothes you have for the said procedure will suffice. That's more or less what happens in the substitute (naked people = numbers in the list; clothes = brackets you add to get the desired outcome). I don't know how to put it simpler than this, really. :lol:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Steve_E
Posts: 5
Joined: May 23rd, 2023, 9:53 am

Re: Min/Max Lua script problem

Post by Steve_E »

Yincognito wrote: May 25th, 2023, 2:37 pm Really?! ... like a bunch of naked people that you need to dress up for some event ...
This is getting interesting! :lol:

I do intend to reread the explanations that you have provided - for which I am very grateful - when my head is in a clearer space than what it is at the moment, and when I can devote more time to studying Rainmeter code syntax. At the moment my head has to be in a more creative space and this old brain is not comprehending what it perceives to be new, alien, technical stuff :(
User avatar
Yincognito
Rainmeter Sage
Posts: 8597
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Min/Max Lua script problem

Post by Yincognito »

Steve_E wrote: May 26th, 2023, 5:04 am This is getting interesting! :lol:

I do intend to reread the explanations that you have provided - for which I am very grateful - when my head is in a clearer space than what it is at the moment, and when I can devote more time to studying Rainmeter code syntax. At the moment my head has to be in a more creative space and this old brain is not comprehending what it perceives to be new, alien, technical stuff :(
Ah, well, part of the success of an explanation is to captivate the reader's interest, isn't it? :sly: Yeah, just relax, take your time and do what you need to do, you can come back to this at any time you like. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth