CoffeeBender wrote: ↑September 16th, 2023, 12:18 pm
Here is the full code, I just started making skins so if I have some parts where things are unnecessarily complicated, feel free to educate me
Seeing the whole code it became extremely clear what is wrong.
The [MeasureDownloadPfpImg] measure (which should download the image) gets the URL only when you get executed the IfTrueAction option of the [MeasureCondition] measure, this URL option being set by the IfTrueAction option. But this IfTrueAction option can be executed only when the WebParser measures (here strictly it's about the [MeasurePfp] measure, which is used into the IfCondition) get their values. But since all WebParser measures (namely the [MeasurePfp] measure) need time to get the value, when you load the skin, the [MeasurePfp] measure gets a value after let's say two - three seconds. But when this goes on and the [MeasureDownloadPfpImg] measure gets its URL, it has been updated with no URL (this leads to an error message in the Log), and you have to wait 10 minutes (the default time) until the next update. If you wait so long, you get the image downloaded, but this obviously is not a proper solution. So we have to ask the [MeasureDownloadPfpImg] measure to update right when it gets the URL. This can be done by adding a
[!CommandMeasure "MeasureDownloadPfpImg" "Update"] bang to the IfTrueAction option of the [MeasureCondition] measure. This way, when you get executed the IfTrueAction option, the [MeasureDownloadPfpImg] measure gets its URL and immediately updates.
Additional improvement: as said above in some cases you get error messages in the Log, this being caused by the fact that some options are not explicitly set, being set only after a while. To fix this I probably would add a
Disabled=1 option to the [MeasureDownloadPfpImg] measure (this way getting it disabled), and would enable it when it has to be updated as well, as described above. By this the [MeasureCondition] and [MeasureDownloadPfpImg] measure should look this way:
Code: Select all
[MeasureCondition]
Measure=String
IfCondition=(10000083=[MeasurePfp])
IfTrueAction=[!SetOption MeasureDownloadPfpImg Url "https://enka.network/ui/UI_AvatarIcon_Linette.png"][!EnableMeasure "MeasureDownloadPfpImg"][!CommandMeasure "MeasureDownloadPfpImg" "Update"]
DynamicVariables=1
Disabled=1
[MeasureDownloadPfpImg]
Measure=WebParser
Download=1
Disabled=1
Note that beside the [MeasureDownloadPfpImg] measure, I disabled the [MeasureCondition] measure as well, because otherwise, since the [MeasurePfp] measure has no yet a value when you refresh the skin either, you get another error message in Log. By disabling this measure, its IfCondition is not executed, so you get no URL for the [MeasureDownloadPfpImg] measure. To enable the measure, add a
FinishAction=[!EnableMeasure "MeasureCondition"][!UpdateMeasure "MeasureCondition"] option to the [MeasureSite] measure. Thi soption is executed when the measure finishes parsing the source. In this moment the WebParser measures get values and all further measures can execute properly, with no error messages.
Just in case you couldn't deal with all this, here is the full and altered code:
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
[MeasureSite]
Measure=WebParser
URL=https://enka.network/api/uid/814702936
RegExp=(?siU){"playerInfo":.*{"nickname":"(.*)".*"level":(.*),.*"signature":"(.*)".*"worldLevel":(.*),.*"profilePicture":{"avatarId":(.*)}}.*"uid":"(.*)"}
Update=3200
FinishAction=[!EnableMeasure "MeasureCondition"][!UpdateMeasure "MeasureCondition"]
;=========================[Player Profile Meausre]====================
[MeasureIgn]
;Takes the Player's IGN
Measure=WebParser
Url=[MeasureSite]
StringIndex=1
[MeasureAR]
;Takes the Player's Adventure Rank
Measure=WebParser
Url=[MeasureSite]
StringIndex=2
[MeasureSign]
;Takes the Player's Signature
Measure=WebParser
Url=[MeasureSite]
StringIndex=3
[MeasureWL]
;Takes the Player's World Level
Measure=WebParser
Url=[MeasureSite]
StringIndex=4
[MeasurePfp]
;Takes the Player's Profile picture's ID
Measure=WebParser
Url=[MeasureSite]
StringIndex=5
[MeasureUID]
;Takes the Player's UID
Measure=WebParser
Url=[MeasureSite]
StringIndex=6
;=========================[Player Profile Meters]====================
[MeterProfileBackground]
;Profile Background
Meter=Image
W=320
H=150
SolidColor=20,20,20,127
[MeterPfp]
;Profile picture Background
Meter=Shape
Shape=Rectangle 10,10,100,100 | Fill Color 20,20,20,127 | StrokeWidth 0
Hidden=0
[MeterUid]
;Player UID
Meter=String
MeasureName=MeasureUid
X=60
Y=5R
FontFace=HYWenHei-85W
FontSize=11
FontColor=252,251,202,255
Padding=5,5,5,5
StringAlign=Center
AntiAlias=1
[MeterIgn]
;Player In Game Name(IGN)
Meter=String
MeasureName=MeasureIgn
X=115
Y=20
FontFace=HYWenHei-85W
FontSize=20
FontColor=252,251,202,255
Padding=5,5,5,5
StringAlign=Left
AntiAlias=1
[MeterARLabel]
;"AR" Label
Meter=String
X=115
Y=60
FontFace=HYWenHei-85W
FontSize=11
FontColor=252,251,202,255
Padding=5,5,5,5
StringAlign=Left
AntiAlias=1
Text=AR
[MeterAR]
;PLayer Adventure Rank
Meter=String
MeasureName=MeasureAR
X=0R
Y=60
FontFace=HYWenHei-85W
FontSize=11
FontColor=252,251,202,255
Padding=5,5,5,5
StringAlign=Left
AntiAlias=1
[MeterWLLabel]
;"WL" Label
Meter=String
X=0R
Y=60
FontFace=HYWenHei-85W
FontSize=11
FontColor=252,251,202,255
Padding=5,5,5,5
StringAlign=Left
AntiAlias=1
Text=- WL
[MeterWL]
;Player World Level
Meter=String
MeasureName=MeasureWL
X=0R
Y=60
FontFace=HYWenHei-85W
FontSize=11
FontColor=252,251,202,255
Padding=5,5,5,5
StringAlign=Left
AntiAlias=1
[MeterSign]
;Player Signature
Meter=String
MeasureName=MeasureSign
X=115
Y=90
FontFace=HYWenHei-85W
FontSize=11
FontColor=252,251,202,200
Padding=5,5,5,5
StringAlign=Left
AntiAlias=1
;====================[Image Download]====================
[MeterDownloadPfpImg]
;For Downloading The Profile Picture
Meter=Image
MeasureName=MeasureDownloadPfpImg
X=10
Y=10
H=100
W=100
[MeasureCondition]
Measure=String
IfCondition=(10000083=[MeasurePfp])
IfTrueAction=[!SetOption MeasureDownloadPfpImg Url "https://enka.network/ui/UI_AvatarIcon_Linette.png"][!EnableMeasure "MeasureDownloadPfpImg"][!CommandMeasure "MeasureDownloadPfpImg" "Update"]
DynamicVariables=1
Disabled=1
[MeasureDownloadPfpImg]
Measure=WebParser
Download=1
Disabled=1
Note one more: Rainmeter is not a programming language and as such, the comments (unlike in any real programming language) have to be added into new lines. If you want to add a comment, the comment has to be the only thing of the line. Comments after and options or section names are not alowed. This is why in the above code I moved all comments into new lines. You have some details
here.