It is currently March 28th, 2024, 4:00 pm

Executing IfMatch only once when skin starts with true condition / saving dynamic variables

Get help with creating, editing & fixing problems with skins
Post Reply
Wyse
Posts: 2
Joined: March 6th, 2017, 10:26 pm

Executing IfMatch only once when skin starts with true condition / saving dynamic variables

Post by Wyse »

Hi,
I've been working on a skin which is supposed to keep track of how many competitive games I've played in a week in Overwatch and display how many games are left to play to avoid MMR decay. I got most of it figured it out, but to be honest I kind of got stuck in the most important parts. Here's the code:

Code: Select all

[Rainmeter]
Update=1000

[Background]
Meter=Image
W=180
H=62
SolidColor=0,0,0,20

[RefreshStats]
Measure=Plugin
Plugin=WebParser
URL=https://overwatchtracker.com/profile/pc/eu/Wyse-2346?update=1
RegExp=
UpdateRate=300

[MeasureRating]
Measure=Plugin
Plugin=WebParser
URL=https://overwatchtracker.com/profile/pc/eu/Wyse-2346?mode=1
RegExp=(?siU)Skill</span>.*"value">(.*)<
UpdateRate=310
StringIndex=1
IfCondition=(MeasureRating >= 0) && (MeasureRating <= 1499)
IfTrueAction=[!SetOption RankIcon ImageName "Bronze.png"]
IfCondition2=(MeasureRating >= 1500) && (MeasureRating <= 1999)
IfTrueAction2=[!SetOption RankIcon ImageName "Silver.png"]
IfCondition3=(MeasureRating >= 2000) && (MeasureRating <= 2499)
IfTrueAction3=[!SetOption RankIcon ImageName "Gold.png"]
IfCondition4=(MeasureRating >= 2500) && (MeasureRating <= 2999)
IfTrueAction4=[!SetOption RankIcon ImageName "Platinum.png"]
IfCondition5=(MeasureRating >= 3000) && (MeasureRating <= 3499)
IfTrueAction5=[!SetOption RankIcon ImageName "Diamond.png"]
IfCondition6=(MeasureRating >= 3500) && (MeasureRating <= 3999)
IfTrueAction6=[!SetOption RankIcon ImageName "Master.png"]
IfCondition7=MeasureRating >= 4000
IfTrueAction7=[!SetOption RankIcon ImageName "Grandmaster.png"]

[MeasureGamesPlayed]
Measure=Plugin
Plugin=WebParser
URL=https://overwatchtracker.com/profile/pc/eu/Wyse-2346?mode=1
RegExp=(?siU)Games Won.*"value">(.*)<
UpdateRate=310
StringIndex=1
OnUpdateAction=[!SetVariable GamesNew [MeasureGamesPlayed]]

[Variables]
GamesOld=
GamesNew=

[MeasureDate]
Measure=Time
Format=%A
IfMatchMode=1
IfMatch=Monday
IfMatchAction=[!SetVariable GamesOld [MeasureGamesPlayed]]
DynamicVariables=1

[MeterGamesNeeded]
Meter=String
MeasureName=CalcGamesNeeded
Y=45
X=55
FontSize=8
FontColor=0, 0, 0, 160
AntiAlias=1
FontFace=Tahoma
Text=
DynamicVariables=1

[CalcGamesNew]
Measure=Calc
Formula=#GamesNew# - #GamesOld#

[CalcGamesNeeded]
Measure=Calc
Formula=7 - [CalcGamesNew]
IfCondition=CalcGamesNeeded <= 0
IfTrueAction=[!SetOption MeterGamesNeeded Text "No games needed."]
IfCondition2=CalcGamesNeeded > 0
IfTrueAction2=[!SetOption MeterGamesNeeded Text "%1 games needed."]

[Rank]
Meter=String
MeasureName=MeasureRating
FontSize=15
FontColor=0, 0, 0, 160
AntiAlias=1
Text=%1
X= 67
Y= 20

[RankIcon]
Meter=Image
ImageName=
W=64
H=64
As you can see the skin uses WebParser's regular expressions to scrape data from a website, but that's already working and the link to my profile is already included for debugging purposes. I didn't include the images but I don't believe those are essential.
Here's what I'm missing:
- The section [MeasureDate] is supposed to save the number of total played games to the GamesOld variable when the weekday is equal to Monday (which is the day of the "reset"). However, this has to happen even when the skin is launched and it's already Monday, hence the IfMatchMode=1; this causes a different problem though: the IfMatchAction has to be only run once, otherwise if games are played on Monday they will not count as games played in the current week but in the past one.
- The GamesOld variable needs to be saved even after the skin is stopped. I'm assuming this doesn't happen because I'm using dynamic variables, but when using static ones I always seem to run into the problem of endless loops because then I would need to refresh the skin when the IfMatchAction is executed.
Are there any ways to implement those two features? I'd appreciate any help since I can't really seem to figure this one out.
Thanks for taking the time to read!

EDIT: Okay, I think I figured it out thanks to jsmorley's code provided here:https://forum.rainmeter.net/viewtopic.php?t=15568
I'll probably need to do some more testing, but it seems to be working fine now.
Post Reply