It is currently April 20th, 2024, 2:55 pm

File size problem in lua

Discuss the use of Lua in Script measures.
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: File size problem in lua

Post by Brian »

SilverAzide wrote: February 3rd, 2022, 12:30 am Wow... this seems a somewhat insurmountable problem! Best of luck on this challenge!
Hopefully this is fixed in next release. In the meantime, you can test this pre-release for any issues: https://forum.rainmeter.net/viewtopic.php?t=39900

-Brian
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: File size problem in lua

Post by Brian »

Yincognito wrote: February 3rd, 2022, 11:15 am I'll use this thread instead of creating another one, taking advantage that you'll be working on this issue, and ask: is there any way to combine Lua's inline syntax with the section variable parameters? I'm thinking of something like:

Code: Select all

[&MS_Script_Timer:td:/100]
where MS_Script_Timer is my Script measure, td is a Lua variable holding a number / string made of 3 digits (i.e. from '000' to '999' or if I convert it to a number in Lua, from 0 to 999), and the idea of dividing this by 100 is to shorten a specific display of it in the skin down to just its first digit without creating another variable for that purpose.

If it's not possible yet, can it be reasonably easily implemented, since you're working on such related parsing? I'll take a no for an answer, I just wanted to find out if such a syntax combination is possible or not. :D
If anyone is interested, this is part of my newly developed Lua timer, which looks like:

Code: Select all

function Initialize()
  state, th, tm, ts, td, ih, im, is, id, value, pt, ct, dt, it = 'Idle', '00', '00', '00', '000', '00', '00', '00', '000', '', os.clock(), 0, 0, 0
end

function Update()
  ct = os.clock()
  if state == 'Reset' then st = ct elseif state == 'Start' or state == 'Idle' then st = ct - dt end
  dt = ct - st
  td = string.format('%03d', math.floor(dt * 1000 % 1000))
  ts = string.format('%02d', math.floor(dt % 60))
  tm = string.format('%02d', math.floor(dt % 3600 / 60))
  th = string.format('%02d', math.floor(dt / 3600))
  if state ~= 'Idle' and state ~= 'Busy' then it = ct - pt; pt = ct end
  id = string.format('%03d', math.floor(it * 1000 % 1000))
  is = string.format('%02d', math.floor(it % 60))
  im = string.format('%02d', math.floor(it % 3600 / 60))
  ih = string.format('%02d', math.floor(it / 3600))
  if state ~= 'Idle' and state ~= 'Busy' then value = (state == 'Reset' and '' or value .. '∆ ' .. state .. ' (total: ' .. th .. ':' .. tm .. ':' .. ts .. '.' .. td .. ', interval: ' .. ih .. ':' .. im .. ':' .. is .. '.' .. id .. ')\n') end
  state = ((state == 'Start' or state == 'Split' or state == 'Busy') and 'Busy' or 'Idle')
  return value
end

function StartPause()
  if state == 'Idle' then state = 'Start' else state = 'Pause' end
  return true
end

function ResetSplit()
  if state == 'Idle' then state = 'Reset' else state = 'Split' end
  return true
end
with the relevant skin part like:

Code: Select all

[MT_Rainmeter_Time]
Meter=String
MeterStyle=SCell | SPrimaryColText
Text="[&MS_Script_Timer:th]:[&MS_Script_Timer:tm]:[&MS_Script_Timer:ts].[&MS_Script_Timer:td:/100]"
Basically, the td variable holds the number of milliseconds in the timer, which I'm trying to fit in a limited space in the skin (letting it full in the tooltip though).
EDIT: Just tried a nested syntax like Text=".[&[&MS_Script_Timer:td]:/100,0]" and it didn't work either.
EDIT2: In the end I managed to fit everything as desired without shortening stuff, but I'd still be interested if the above is possible, out of curiosity.
To me, this isn't a question of feasibility, but more of "should we do it" situation.

What you are describing is a "stacking" of meter/measure parameters that are available to section names. Like taking the output of the referenced section, then applying some formatting (with the use of meter/measure parameters), then applying more formatting based on another set of meter/measure parameters....and so on.

I realize in your specific examples, you basically want to modify the output of a variable from lua....but given all the other options of meter/measure parameters, it might be best to just come up with custom lua function that could do the extra processing for you.
Example: Text="[&MS_Script_Timer:th]:[&MS_Script_Timer:tm]:[&MS_Script_Timer:ts].[&MS_Script_Timer:Percentage(td/100)]"

-Brian
User avatar
Yincognito
Rainmeter Sage
Posts: 7132
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: File size problem in lua

Post by Yincognito »

Brian wrote: February 3rd, 2022, 9:09 pm To me, this isn't a question of feasibility, but more of "should we do it" situation.

What you are describing is a "stacking" of meter/measure parameters that are available to section names. Like taking the output of the referenced section, then applying some formatting (with the use of meter/measure parameters), then applying more formatting based on another set of meter/measure parameters....and so on.

I realize in your specific examples, you basically want to modify the output of a variable from lua....but given all the other options of meter/measure parameters, it might be best to just come up with custom lua function that could do the extra processing for you.
Example: Text="[&MS_Script_Timer:th]:[&MS_Script_Timer:tm]:[&MS_Script_Timer:ts].[&MS_Script_Timer:Percentage(td/100)]"

-Brian
You're right, in the general case this "stacking" could go on forever and wouldn't be something to consider working on. The additional Lua function is a good idea, just like creating another Lua variable for that purpose, but in that case I focused on doing things without additional code. Luckily, as I mentioned, the shortening of that variable is no longer necessary since now I use the full / complete value everywhere after doing some shuffling in my skin's layout. Thanks for answering, it's good to know what can be done and what can't - at least in the way I initially envisioned.

By the way, I just tested the new pre-release Rainmeter version on my usual skins (my suite, which uses nested variable syntax quite extensively in a few places, plus my "old" current section index test skin from when you were working on that), and so far it works without issues. I didn't try too much using different Lua / nested syntax variations similar to the ones in this thread, only tested the basic one which seems to work as well. It'll be up to balala and other folks who already have the suited code in place to see if they encounter any issues with the pre-release version in regard to that, all I can say is that for the skins I tested it on, it didn't produce any drawbacks. I wasn't sure whether to post this here or on the Pre-Release Testing section fo the forum, so given my other question I decided to post this here as well - I hope it's alright.

Good job, by the way! :thumbup: I don't like insurmountable problems either, I try very hard to make them 'surmountable' (so to speak) as well... :lol:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16150
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: File size problem in lua

Post by balala »

Brian wrote: February 3rd, 2022, 8:57 pm Hopefully this is fixed in next release. In the meantime, you can test this pre-release for any issues: https://forum.rainmeter.net/viewtopic.php?t=39900
Thanks. Tomorrow will test it (here is almost midnight, so don't work today anymore) and will come back. Thank you.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2604
Joined: March 23rd, 2015, 5:26 pm

Re: File size problem in lua

Post by SilverAzide »

Brian wrote: February 3rd, 2022, 8:57 pm Hopefully this is fixed in next release. In the meantime, you can test this pre-release for any issues: https://forum.rainmeter.net/viewtopic.php?t=39900

-Brian
So far, so good, with my simple tests. :thumbup: But as they say, absence of evidence is not evidence of absence, so... ;-)
Gadgets Wiki GitHub More Gadgets...
User avatar
Yincognito
Rainmeter Sage
Posts: 7132
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: File size problem in lua

Post by Yincognito »

Brian wrote: February 3rd, 2022, 8:57 pm Hopefully this is fixed in next release. In the meantime, you can test this pre-release for any issues: https://forum.rainmeter.net/viewtopic.php?t=39900

-Brian
Ok, I set up a simple test skin and I noticed some problems...

\@Resources\Script.lua:

Code: Select all

function Function(variable)
  return variable
end
\Test.ini:

Code: Select all

[Variables]
FileNames=4
FileIndex=0
FileName0=File[3].png
FileName1=File [3].png
FileName2=File[3][5].png
FileName3=File[3[5]].png

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

---Measures---

[Script]
Measure=Script
ScriptFile=#@#Script.lua
UpdateDivider=-1
DynamicVariables=1

---Meters---

[MeterTest]
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text=Script = [&Script:Function('[#FileName[#FileIndex]]')]
MouseScrollUpAction=[!SetVariable FileIndex ((#FileNames#+#FileIndex#-1)%#FileNames#)][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable FileIndex ((#FileNames#+#FileIndex#+1)%#FileNames#)][!UpdateMeter *][!Redraw]
UpdateDivider=-1
DynamicVariables=1
As always for my codes, scroll up and down to see the results. The first 2 file names work, the last 2 don't. I don't know if this was meant to handle multiple or nested '[something]' occurrences, but that is one situation where the pre-release version doesn't quite nail it.

The simple 'somename [sometext]' variants do work though... :???:

P.S. As far as file names are concerned, while the nested form above is not usually encountered, Windows and other programs have the habit of adding either ' (number)', or ' [number]' or '_number' to files created to avoid overwriting duplicates, albeit the ' [number]' form is less encountered in my experience. Strictly from my point of view, I'd find it easier to just mass rename files to avoid the square brackets - preferably turning them into round brackets - instead of battling escaping N ways of arranging those square brackets in a file name or any other text. But then, that's just me, and for folks (still) using Windows Explorer's limited functions, mass renaming wouldn't be as easy to accomplish as it's for someone using an alternative "Explorer" / "Commander" where such a task is as easy as mass renaming text occurrences in a Notepad++ file (including using regex for that, by the way)...

EDIT: One last thought ... to me, the simplest way to escape such square brackets would be to use Rainmeter's own [*blablablah*] syntax already employed when it comes to normal section variables. Unfortunately, this requires substituting the square bracket occurrences in the corresponding measures, which might not be desirable when trying to use the original file names elsewhere where escaping would not be needed. Not sure such an escaping would be entirely passable to Lua either. :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: File size problem in lua

Post by Brian »

Yincognito wrote: February 3rd, 2022, 10:18 pm Ok, I set up a simple test skin and I noticed some problems...
Thanks for this. Once I saw some of the different bracket options you provided, I realized my mistake or rather my assumption.

I totally revised the parsing function for nested syntax. Well, not totally revised, but at least some of the logic in determining "where" the variable definition is located within a string.

Anyway...you can get it here: https://forum.rainmeter.net/viewtopic.php?p=203898#p203912

-Brian
User avatar
Yincognito
Rainmeter Sage
Posts: 7132
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: File size problem in lua

Post by Yincognito »

Brian wrote: February 4th, 2022, 9:54 am Thanks for this. Once I saw some of the different bracket options you provided, I realized my mistake or rather my assumption.

I totally revised the parsing function for nested syntax. Well, not totally revised, but at least some of the logic in determining "where" the variable definition is located within a string.

Anyway...you can get it here: https://forum.rainmeter.net/viewtopic.php?p=203898#p203912

-Brian
Hmm...well, it works alright for the 'something1 [something2]' stuff in this thread, including my test skin above, but it gives a ton of (same) errors in the skins from my MYiniMeter suite, even the most basic ones. Oh and Rainmeter will go into the "not responding" state, having to be closed down from Task Manager, of course:
Errors Rainmeter 4.5.11.3599 PR.jpg
I hate to make you decipher my code like that (jsmorley would probably go crazy about it if it were him, haha!), but I'm not sure where to begin in order to build a simple skin showcasing the error, so I'd just pick the simplest skin from the suite (say, Rainmeter.ini, since the equally simple Wifi.ini doesn't seem to produce the error - guess it's way too simple for that) and try to figure out where the error comes from. It probably has to do with variables, judging by the look of the error. The suite skins have the usual common dependencies, like Variables.inc, Styles.inc, Rainmeter.inc, aside from a more special one named Design.inc which handles the dimensions, visual sections and bevels in skins.

In any case, I'll probably try to build a simpleton skin for the error later on, if I'm lucky to determine when the error appears exactly, so if you don't figure the things out by then, I'll help you out for sure. I'll keep you posted if I'm on to something...
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7132
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: File size problem in lua

Post by Yincognito »

Brian wrote: February 4th, 2022, 9:54 am Thanks for this. Once I saw some of the different bracket options you provided, I realized my mistake or rather my assumption.

I totally revised the parsing function for nested syntax. Well, not totally revised, but at least some of the logic in determining "where" the variable definition is located within a string.

Anyway...you can get it here: https://forum.rainmeter.net/viewtopic.php?p=203898#p203912

-Brian
Ok, here are some simpler examples of skins from my "repertoire" that give the error(s) I mentioned above for the Rainmeter-4.5.11.3599-prerelease version:

BaseConverter.ini:

Code: Select all

[Variables]
Number=2744
Quotient=(#Number#)
Result=""
Base=20

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

---Measures---

[MeasureConvert]
Measure=Calc
Formula=(#Quotient#%#Base#)
UpdateDivider=-1
RegExpSubstitute=1
Substitute="^10$":"A","^11$":"B","^12$":"C","^13$":"D","^14$":"E","^15$":"F","^16$":"G","^17$":"H","^18$":"I","^19$":"J","^20$":"K","^21$":"L","^22$":"M","^23$":"N","^24$":"O","^25$":"P","^26$":"Q","^27$":"R","^28$":"S","^29$":"T","^30$":"U","^31$":"V","^32$":"W","^33$":"X","^34$":"Y","^35$":"Z"
IfCondition=((#Quotient#)<>0)
IfTrueAction=[!SetVariable Result "[MeasureConvert]#Result#"][!SetVariable Quotient (Trunc(#Quotient#/#Base#))][!UpdateMeasure "MeasureConvert"]
IfConditionMode=1
DynamicVariables=1

---Meter---

[MeterConvert]
Meter=STRING
X=5
Y=5
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text="Number = #Number##CRLF#Base   = #Base##CRLF#Result = #Result#"
DynamicVariables=1
ColorWheelA.ini:

Code: Select all

[Variables]
; Color Array (set it to a "<ColorNumber>:<Red>,<Green>,<Blue>,<Alpha>;" enumeration)
Colors="0:255,0,0,255;1:255,0,255,255;2:0,0,255,255;3:0,255,255,255;4:0,255,0,255;5:255,255,0,255;6:255,0,0,255;"
; Maximum Value (decrease to speed up the transition, increase to slow it down)
Range=384
; Value's Step (decrease to slow down the transition, increase to speed it up; negative values to transition backwards)
VStep=1

[Rainmeter]
Update=25
DynamicWindowSize=1
AccurateText=1

---Measures---

[SetRGBA]
Measure=String
String=#Colors#
UpdateDivider=-1
RegExpSubstitute=1
Substitute="(?U)(.+):(.+),(.+),(.+),(.+);":"[!SetVariable R\1 \2][!SetVariable G\1 \3][!SetVariable B\1 \4][!SetVariable A\1 \5]","(\d+)(\s+\S+\])$":"\1\2[!SetVariable IdMax \1]","(?U)^(\[.+\s+(\S+)\]\[.+\s+(\S+)\]\[.+\s+(\S+)\]\[.+\s+(\S+)\])":"[!SetVariable R \2][!SetVariable G \3][!SetVariable B \4][!SetVariable A \5]\1"
OnUpdateAction=[SetRGBA]

[Value]
Group=ColorGroup
Disabled=1
Measure=Calc
Formula=((#Range#+Value+#VStep#)%#Range#)
OnUpdateAction=[!SetVariable Interval (([#Range]+1)/[#IdMax])][!SetVariable SIndex (Trunc([Value]/(([#Range]+1)/[#IdMax])))][!SetVariable EIndex (Trunc([Value]/(([#Range]+1)/[#IdMax]))+1)]
DynamicVariables=1

[Color]
Group=ColorGroup
Disabled=1
Measure=Calc
OnUpdateAction=[!SetVariable R ([#R[#SIndex]]+(([Value]-[#SIndex]*[#Interval])/[#Interval])*([#R[#EIndex]]-[#R[#SIndex]]))][!SetVariable G ([#G[#SIndex]]+(([Value]-[#SIndex]*[#Interval])/[#Interval])*([#G[#EIndex]]-[#G[#SIndex]]))][!SetVariable B ([#B[#SIndex]]+(([Value]-[#SIndex]*[#Interval])/[#Interval])*([#B[#EIndex]]-[#B[#SIndex]]))][!SetVariable A "255"][!UpdateMeter "Shape"][!Redraw]
RegExpSubstitute=1
Substitute="^.*$":"#R#,#G#,#B#,#A#","\.\d+":"","(\d+)":"  \1","[ \d]*([ \d]{3})":"\1"," ":"  "
DynamicVariables=1

---Meters---

[Shape]
Meter=Shape
Shape=Rectangle 0,0,200,100,12 | StrokeWidth 0 | Stroke Color 255,255,255,255 | Fill Color #R#,#G#,#B#,#A#
MouseScrollDownAction=[!SetVariable VStep -1][!EnableMeasureGroup ColorGroup][!UnpauseMeasureGroup ColorGroup][!UpdateMeasureGroup ColorGroup][!PauseMeasureGroup ColorGroup][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseScrollUpAction=[!SetVariable VStep 1][!EnableMeasureGroup ColorGroup][!UnpauseMeasureGroup ColorGroup][!UpdateMeasureGroup ColorGroup][!PauseMeasureGroup ColorGroup][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
LeftMouseUpAction=[!UnpauseMeasureGroup ColorGroup][!ToggleMeasureGroup ColorGroup][!SetVariable R #R0#][!SetVariable G #G0#][!SetVariable B #B0#][!SetVariable A #A0#][!UpdateMeasureGroup ColorGroup][!UpdateMeter #CURRENTSECTION#][!Redraw]
MiddleMouseUpAction=[!TogglePauseMeasureGroup ColorGroup]
DynamicVariables=1

[Text]
Meter=STRING
X=([Shape:W]/2)r
Y=([Shape:H]/2)r
W=([Shape:W])
H=([Shape:H])
FontFace=Tahoma
FontColor=255,255,255,255
FontSize=10
FontWeight=700
AntiAlias=1
StringAlign=CenterCenter
StringEffect=Shadow
FontEffectColor=0,0,0,255
Text="TRANSITION: Color Wheel#CRLF#DIRECTION: #VStep##CRLF#COLOR: [Color]#CRLF#TRANSITION UPDATES: #Range#"
DynamicVariables=1
CombineTM.ini:

Code: Select all

[Variables]
GlobalW=(600*[#Scale])
GlobalH=(600*[#Scale])
LocalW=(100*[#Scale])
LocalH=(50*[#Scale])
Scale=0.49
LocalStyle=0

[Rainmeter]
Update=25
DynamicWindowSize=1
AccurateText=1

---Measures---

[LocalStyle]
Measure=String
String=#LocalStyle#
UpdateDivider=-1
RegExpSubstitute=1
Substitute="^0$":"TM_Two","^1$":"TM_Out"
DynamicVariables=1

[Angle1]
Measure=Calc
Formula=((Angle1+1)%360)
DynamicVariables=1

[Angle2]
Measure=Calc
Formula=((Angle2+1)%360)
DynamicVariables=1

---Styles---

; TransformationMatrix [TM in short] multiplication (syntax changes: "zoom" = "scale", "a" = 2nd matrix "x", "b" = 2nd matrix "y")
;
; | zoomx  skewx  movex |   | zooma  skewa  movea |   | zoomx*zooma+skewx*skewb+movex*0  zoomx*skewa+skewx*zoomb+movex*0  zoomx*movea+skewx*moveb+movex*1 |
; | skewy  zoomy  movey | x | skewb  zoomb  moveb | = | skewy*zooma+zoomy*skewb+movey*0  skewy*skewa+zoomy*zoomb+movey*0  skewy*movea+zoomy*moveb+movey*1 |
; |   0      0      1   |   |   0      0      1   |   |     0*zooma+    0*skewb+    1*0      0*skewa+    0*zoomb+    1*0      0*movea+    0*moveb+    1*1 |
;
; In Rainmeter (column by column and separated by ";" order of the above, excluding the 3rd row containing the "0  0  1" values)
;
; 1st matrix: TransformationMatrix=zoomx;skewy;skewx;zoomy;movex;movey
; 2nd matrix: TransformationMatrix=zooma;skewb;skewa;zoomb;movea;moveb
; out matrix: TransformationMatrix=(zoomx*zooma+skewx*skewb);(skewy*zooma+zoomy*skewb);(zoomx*skewa+skewx*zoomb);(skewy*skewa+zoomy*zoomb);(zoomx*movea+skewx*moveb+movex);(skewy*movea+zoomy*moveb+movey)
;
; Hint: copy the out matrix, place its values on different lines, replace operands with the corresponding 1st and 2nd matrix values, regroup lines into one
;
; The code below demonstrates applying a local TM at the meter level (2nd matrix) over a global TM at the skin level (1st matrix) through TM1 x TM2 operation
; - [Background]: dummy meter used to workaround the transformed window / skin size issues mentioned at https://forum.rainmeter.net/viewtopic.php?f=14&t=37848
; - [Global]: meter used to simulate the skin itself and to showcase the 1st matrix transformation, i.e. rotation of a rectangle around the global center
; - [Local]: meter used to showcase both the 2nd and the out matrix transformations, i.e. rotation of a rectangle around its center ± around the global center
; - out matrix uses skin specific coordinates, aka 0 for [#CURRENTSECTION#:X or Y], #CURRENTCONFIGWIDTH# & #CURRENTCONFIGHEIGHT# for [#CURRENTSECTION#:W or H]

[TM_One]
TransformationMatrix=(Cos(Rad([Angle1:])));(-Sin(Rad([Angle1:])));(Sin(Rad([Angle1:])));(Cos(Rad([Angle1:])));(([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)-([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*Cos(Rad([Angle1:]))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*Sin(Rad([Angle1:])));(([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)+([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*Sin(Rad([Angle1:]))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*Cos(Rad([Angle1:])))

[TM_Two]
TransformationMatrix=(Cos(Rad([Angle2:])));(-Sin(Rad([Angle2:])));(Sin(Rad([Angle2:])));(Cos(Rad([Angle2:])));(([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)-([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*Cos(Rad([Angle2:]))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*Sin(Rad([Angle2:])));(([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)+([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*Sin(Rad([Angle2:]))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*Cos(Rad([Angle2:])))

[TM_Out]
TransformationMatrix=(Cos(Rad([Angle1:]))*Cos(Rad([Angle2:]))-Sin(Rad([Angle1:]))*Sin(Rad([Angle2:])));(-Sin(Rad([Angle1:]))*Cos(Rad([Angle2:]))-Cos(Rad([Angle1:]))*Sin(Rad([Angle2:])));(Cos(Rad([Angle1:]))*Sin(Rad([Angle2:]))+Sin(Rad([Angle1:]))*Cos(Rad([Angle2:])));(-Sin(Rad([Angle1:]))*Sin(Rad([Angle2:]))+Cos(Rad([Angle1:]))*Cos(Rad([Angle2:])));(Cos(Rad([Angle1:]))*(([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)-([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*Cos(Rad([Angle2:]))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*Sin(Rad([Angle2:])))+Sin(Rad([Angle1:]))*(([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)+([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*Sin(Rad([Angle2:]))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*Cos(Rad([Angle2:])))+((0+#CURRENTCONFIGWIDTH#/2)-(0+#CURRENTCONFIGWIDTH#/2)*Cos(Rad([Angle1:]))-(0+#CURRENTCONFIGHEIGHT#/2)*Sin(Rad([Angle1:]))));(-Sin(Rad([Angle1:]))*(([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)-([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*Cos(Rad([Angle2:]))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*Sin(Rad([Angle2:])))+Cos(Rad([Angle1:]))*(([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)+([#CURRENTSECTION#:X]+[#CURRENTSECTION#:W]/2)*Sin(Rad([Angle2:]))-([#CURRENTSECTION#:Y]+[#CURRENTSECTION#:H]/2)*Cos(Rad([Angle2:])))+((0+#CURRENTCONFIGHEIGHT#/2)+(0+#CURRENTCONFIGWIDTH#/2)*Sin(Rad([Angle1:]))-(0+#CURRENTCONFIGHEIGHT#/2)*Cos(Rad([Angle1:]))))

---Meters---

[Background]
Meter=Image
W=#GlobalW#
H=#GlobalH#
SolidColor=0,0,0,128
UpdateDivider=-1
LeftMouseUpAction=[!SetVariable LocalStyle (1-#LocalStyle#)][!UpdateMeasure LocalStyle][!UpdateMeter *][!Redraw]
MouseScrollUpAction=[!SetVariable Scale (Clamp(#Scale#+0.01,0.01,2))][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable Scale (Clamp(#Scale#-0.01,0.01,2))][!UpdateMeter *][!Redraw]
DynamicVariables=1

[Global]
Hidden=#LocalStyle#
Meter=Shape
MeterStyle=TM_One
W=#GlobalW#
H=#GlobalH#
Shape=Rectangle (#GlobalW#-#LocalW#-(Sqrt(#LocalW#**2+#LocalH#**2)-#LocalW#)/2),(#GlobalH#/2-#LocalH#/2),#LocalW#,#LocalH# | StrokeWidth 0 | Stroke Color 255,255,0,255 | Fill Color 255,255,0,255
DynamicVariables=1

[Local]
Meter=Shape
MeterStyle=[LocalStyle]
X=(#GlobalW#-#LocalW#-(Sqrt(#LocalW#**2+#LocalH#**2)-#LocalW#)/2)
Y=(#GlobalH#/2-#LocalH#/2)
Shape=Rectangle 0,0,#LocalW#,#LocalH# | StrokeWidth 0 | Stroke Color 255,255,0,255 | Fill Color 255,255,0,255
DynamicVariables=1
Errors Rainmeter 4.5.11.3599 PR II.jpg
These are simple and short skins, with no dependencies whatsoever, so they should be easier to debug... :???:
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7132
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: File size problem in lua

Post by Yincognito »

Brian wrote: February 4th, 2022, 9:54 amAnyway...you can get it here: https://forum.rainmeter.net/viewtopic.php?p=203898#p203912
I'm sure that if you already read my replies (especially the last one), you would have pretty much identified when the error happens, but just for reference, here is the simplest case of all (comments are self explanatory):

Code: Select all

[Variables]
Variable=0

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

---Measures---

[SomeMeasure]
Measure=Calc
Formula=0
UpdateDivider=-1
IfCondition=(1=1)
; Error Below: Cannot replace variable with itself "SomeMeasure"
IfTrueAction=[!SetVariable Variable "[SomeMeasure]#Variable#"]
; Error Below: Cannot replace variable with itself "SomeMeasure][SomeMeasure"
IfFalseAction=[!SetVariable Variable "[SomeMeasure][SomeMeasure]"]
DynamicVariables=1

---Meter---

[SomeMeter]
Meter=STRING
X=5
Y=5
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text="Nothing"
DynamicVariables=1
There might be more variations of this, maybe for different places where such parts exist in the code, or maybe for different formats measures (or meters and/or variables?) could take i.e. numeric instead of string, but that is the basic showcase of what happens - hope that helps. ;-)

EDIT: "Complete" test code that aggregates both the square brackets (otherwise partially working if not for the errors like "Invalid function call: Function('File [aghgf") and replacing variables with themselves stuff (the " Cannot replace variable with itself" errors happen when scrolling and changing the file index too, by the way, even though the parsing is not done inside a string but on the option bangs themselves):

Code: Select all

function Function(variable)
  return variable
end

Code: Select all

[Variables]
FileNames=4
FileIndex=0
FileName0=File[3].png
FileName1=File [aghgf].png
FileName2=File[3][5].png
FileName3=File[3[5]].png

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

---Measures---

[Script]
Measure=Script
ScriptFile=#@#Script.lua
UpdateDivider=-1
DynamicVariables=1

[SomeMeasure]
Measure=Calc
Formula=0
UpdateDivider=-1
IfCondition=(1=1)
IfTrueAction=[!SetVariable Variable "[SomeMeasure]#Variable#"]
IfFalseAction=[!SetVariable Variable "[SomeMeasure][SomeMeasure]"]
DynamicVariables=1

---Meters---

[MeterTest]
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
Text=Script = [&Script:Function('[#FileName[#FileIndex]]')]
MouseScrollUpAction=[!SetVariable FileIndex ((#FileNames#+#FileIndex#-1)%#FileNames#)][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable FileIndex ((#FileNames#+#FileIndex#+1)%#FileNames#)][!UpdateMeter *][!Redraw]
UpdateDivider=-1
DynamicVariables=1
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth