Again, I'm attempting to create my first skin where the desktop background changes based on time of day, and weather.
I have 3 "weather conditions" being found - raining, snowing, or hot outside.
And 4 "time conditions" - dawn, day, night, and dusk.
The weather conditions should prioritize over time-related ones.
All of this information is gathered through a WebParser which looks at a http://wxdata.weather.com XML file.
For the weather conditions, I'm hijacking the <icon> bit, which gives a number 1-47, previously explained here https://forum.rainmeter.net/viewtopic.php?t=27709
If, say, the number of <icon> matches something that resembles snow (13), I want the desktop background to change to any random picture that lies within a specific snow-background-folder.
For this matching of <icon> to the desired condition, I'm using the IfCondition option, with a series of OR functions (paired with an ending "IfTrueAction").
My trouble is - I can't get this to work. For some reason if I "number" the first IfCondition option (Rain) and it's attaching IfTrueAction (like make it IfCondition10/IfTrueAction10), it won't do anything when it's given a proper number to make the OR statement true.
But if I leave it "blank" (Just having the option of the measure IfCondition/IfTrueAction) it won't listen to the <icon> number whatsoever - it's ALWAYS true (or at least seems to be?)
An explanation / fix would be GREATLY appreciated.
If you prefer a .rmskin file (I would), here you go:
https://mega.nz/#!yaIEnJga!-3NweN8ntMykRYvcUmfYwe78exm_e8GGsWfa9gcefw4
Note: The file is fairly hefty (217 MB) because of the 1440p / 4K background images.
If not, my code / wall of text:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Metadata]
Name=AdventureTimeChangeBackground
Author=BunnyHelp
Information=
Version=In Development 1.0
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0
[Variables]
WeatherCodeLocation=USOH1000
WeatherUnit=m
[Lua]
Measure=Script
ScriptFile=#@#SunRiseSet.lua
;==============================================
;-------------------MEASURES-------------------
;==============================================
;-------------------WEATHER--------------------
;==============================================
[MeasureWeatherXML]
Measure=WebParser
UpdateRate=1000
Url=http://xml.weather.com/weather/local/#WeatherCodeLocation#?cc=*&unit=#WeatherUnit#&dayf=6
RegExp=(?siU)<tmp>(.*)</tmp>.*<t>(.*)</t>.*<icon>(.*)</icon>.*<sunr>(.*)</sunr>.*<suns>(.*)</suns>.*
[MeasureWeatherTemp]
Measure=WebParser
Url=[MeasureWeatherXML]
StringIndex=1
[MeasureWeatherDescriptionToday]
Measure=WebParser
Url=[MeasureWeatherXML]
StringIndex=2
[MeasureWeatherIcon]
Measure=WebParser
Url=[MeasureWeatherXML]
StringIndex=3
[MeasureSunrise]
Measure=WebParser
Url=[MeasureWeatherXML]
StringIndex=4
[MeasureSunset]
Measure=WebParser
Url=[MeasureWeatherXML]
StringIndex=5
;-------------------TIME--------------------------
;=================================================
[MeasureTime]
Measure=Time
Format=%H:%M
;-------------------DATE--------------------------
;=================================================
[MeasureDate]
Measure=Time
Format=%d
[MeasureMonth]
Measure=Time
Format=of %B
[MeasureYear]
Measure=Time
Format=%Y
;-----------------WALLPAPER-----------------------
;=================================================
[MeasureWallpaperWeather]
Measure=String
IfConditionMode=1
DynamicVariables=1
UpdateDivider=1800
;Rain
IfCondition=(MeasureWeatherIcon = 0) || (MeasureWeatherIcon = 1) || (MeasureWeatherIcon = 2) || (MeasureWeatherIcon = 3) || (MeasureWeatherIcon = 4) || (MeasureWeatherIcon = 9) || (MeasureWeatherIcon = 10) || (MeasureWeatherIcon = 11) || (MeasureWeatherIcon = 12) || (MeasureWeatherIcon = 17) || (MeasureWeatherIcon = 18) || (MeasureWeatherIcon = 35) || (MeasureWeatherIcon = 37) || (MeasureWeatherIcon = 38) || (MeasureWeatherIcon = 39) || (MeasureWeatherIcon = 40) || (MeasureWeatherIcon = 45) || (MeasureWeatherIcon = 47)
IfTrueAction=[!EnableMeasure MeasureRainWallpaper][!SetWallpaper "[MeasureRainWallpaper]" Fill]
;Snow
IfCondition2=(MeasureWeatherIcon = 5) || (MeasureWeatherIcon = 6) || (MeasureWeatherIcon = 7) || (MeasureWeatherIcon = 8) || (MeasureWeatherIcon = 13) || (MeasureWeatherIcon = 14) || (MeasureWeatherIcon = 15) || (MeasureWeatherIcon = 16) || (MeasureWeatherIcon = 41) || (MeasureWeatherIcon = 42) || (MeasureWeatherIcon = 43) ||(MeasureWeatherIcon = 46)
IfTrueAction2=[!EnableMeasure MeasureSnowWallpaper][!SetWallpaper "[MeasureSnowWallpaper]" Fill]
;Hot
IfCondition3=(MeasureWeatherTemp >= 27) || (MeasureWeatherIcon = 36)
IfTrueAction3=[!SetWallpaper "[MeasureHotWallpaper]" Fill]
IfFalseAction3=[!EnableMeasure MeasureWallpaperTime][!UpdateMeasure MeasureWallpaperTime]
[MeasureWallpaperTime]
Measure=String
DynamicVariables=1
UpdateDivider=1800
;Dawn
IfCondition4=([Lua:sunStateString] = Dawn)
IfTrueAction4=[!EnableMeasure MeasureDawnWallpaper][!SetWallpaper "[MeasureDawnWallpaper]" Fill]
;Day
IfCondition5=([Lua:sunStateString] = Day)
IfTrueAction5=[!EnableMeasure MeasureDayWallpaper][!SetWallpaper "[MeasureDayWallpaper]" Fill]
;Night
IfCondition6=([Lua:sunStateString] = Night)
IfTrueAction6=[!EnableMeasure MeasureNightWallpaper][!SetWallpaper "[MeasureNightWallpaper]" Fill]
;Dusk
IfCondition7=([Lua:sunStateString] = Dusk)
IfTrueAction7=[!EnableMeasure MeasureDuskWallpaper][!SetWallpaper "[MeasureDuskWallpaper]" Fill]
Disabled=1
[MeasureDayWallpaper]
UpdateDivider=1800
Measure=Plugin
Plugin=QuotePlugin
PathName=#@#Backgrounds\Day
FileFilter=*.png
Disabled=1
[MeasureRainWallpaper]
UpdateDivider=1800
Measure=Plugin
Plugin=QuotePlugin
PathName=#@#Backgrounds\Rain
FileFilter=*.png
Disabled=1
[MeasureSnowWallpaper]
UpdateDivider=1800
Measure=Plugin
Plugin=QuotePlugin
PathName=#@#Backgrounds\Snow
FileFilter=*.png
Disabled=1
[MeasureHotWallpaper]
UpdateDivider=1800
Measure=Plugin
Plugin=QuotePlugin
PathName=#@#Backgrounds\Hot
FileFilter=*.png
Disabled=1
[MeasureNightWallpaper]
UpdateDivider=1800
Measure=Plugin
Plugin=QuotePlugin
PathName=#@#Backgrounds\Night
FileFilter=*.png
Disabled=1
[MeasureDawnWallpaper]
UpdateDivider=1800
Measure=Plugin
Plugin=QuotePlugin
PathName=#@#Backgrounds\Dawn
FileFilter=*.png
Disabled=1
[MeasureDuskWallpaper]
UpdateDivider=1800
Measure=Plugin
Plugin=QuotePlugin
PathName=#@#Backgrounds\Dusk
FileFilter=*.png
Disabled=1
;============================================
;-------------------STYLES-------------------
;============================================
[StyleText]
FontColor=255,255,255,255
Padding=5,5,5,5
FontSize=20
StringAlign=Left
FontFace=Thunderman
Antialias=1
[StyleTextBigger]
FontColor=255,255,255,255
Padding=5,5,5,5
FontSize=32
StringAlign=Left
FontFace=Thunderman
Antialias=1
[StyleSuperscript]
FontColor=255,255,255,255
Padding=5,5,5,5
FontSize=12
StringAlign=Left
FontFace=Thunderman
Antialias=1
;============================================
;-------------------METERS-------------------
;============================================
[MeterBackground]
Meter=Image
W=520
H=700
SolidColor=20,20,20,100
;-------------------TIME---------------------------
;==================================================
[MeterTime]
Meter=String
MeasureName=MeasureTime
MeterStyle=StyleTextBigger
X=0
Y=5
;-------------------DATE---------------------------
;==================================================
[MeterDate]
Meter=String
MeasureName=MeasureDate
MeterStyle=StyleText
X=-r
Y=50r
[MeterTH]
Meter=String
Text=th
MeterStyle=StyleSuperscript
X=40r
Y=r
[MeterMonth]
Meter=String
MeasureName=MeasureMonth
MeterStyle=StyleText
X=29r
Y=r
[MeterComma]
Meter=String
Text=,
MeterStyle=StyleText
X=102r
Y=2r
[MeterYear]
Meter=String
MeasureName=MeasureYear
MeterStyle=StyleText
X=15r
Y=3r
;-------------------WEATHER------------------
;============================================
[MeterDay]
Meter=String
MeterStyle=StyleText
X=0
Y=155
Prefix="Today"
[MeterDesc]
Meter=String
MeasureName=MeasureWeatherDescriptionToday
MeterStyle=StyleText
X=r
Y=200
[MeterTemp]
Meter=String
MeasureName=MeasureWeatherTemp
MeterStyle=StyleText
X=70r
Y=1r
Postfix="°C"
;These are just for testing that information is being pulled correctly
[MeterIcon]
Meter=String
MeasureName=MeasureWeatherIcon
MeterStyle=StyleText
X=0
Y=50r
[MeterSunset]
Meter=String
MeasureName=MeasureSunset
MeterStyle=StyleText
X=r
Y=50r
[MeterSunrise]
Meter=String
MeasureName=MeasureSunrise
MeterStyle=StyleText
X=r
Y=50r
[MeterMinutesSunrise]
Meter=String
MeterStyle=StyleText
X=r
Y=50r
Text=[Lua:sunStateString]
DynamicVariables=1
[MeterPathTest]
Meter=String
MeterStyle=StyleText
X=r
Y=50r
Text=[MeasureRainWallpaper][MeasureDayWallpaper][MeasureNightWallpaper][MeasureDuskWallpaper][MeasureDawnWallpaper][MeasureHotWallpaper][MeasureSnowWallpaper]
DynamicVariables=1
Code: Select all
function Initialize()
measureSunrise = SKIN:GetMeasure('measureSunrise')
measureSunset = SKIN:GetMeasure('measureSunset')
end
function Update()
inSunrise = measureSunrise:GetStringValue()
inSunset = measureSunset:GetStringValue()
NextChange(inSunrise, inSunset)
return formatString
end
function NextChange(inSunrise, inSunset)
currentTime = os.date('*t')
secondsSinceMidnight = os.time() - os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=0, min=0, sec=0})
secondsTilMidnight = os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=23, min=59, sec=59}) - os.time()
riseHour = string.match(inSunrise, '(.-):')
riseMinute = string.match(inSunrise, '.-:(%d%d)')
setHour = string.match(inSunset, '(.-):') + 12
setMinute = string.match(inSunset, '.-:(%d%d)')
if currentTime.hour >= 0 and currentTime.hour < 12 then
dayStateString = 'Morning'
elseif currentTime.hour >= 12 and currentTime.hour < setHour then
dayStateString = 'Afternoon'
else
dayStateString = 'Evening'
end
if os.time() >= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=setHour, min=setMinute}) then
dayState = 'SunRiseTomorrow'
elseif os.time() <= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=riseHour, min=riseMinute}) then
dayState = 'SunRiseToday'
else
dayState = 'SunSetToday'
end
if dayState == 'SunRiseTomorrow' then
secondsTilChange = secondsTilMidnight + (riseHour * 3600) + (riseMinute * 60)
end
if dayState == 'SunRiseToday' then
secondsTilChange = ((riseHour * 3600) + (riseMinute * 60)) - secondsSinceMidnight
end
if dayState == 'SunSetToday' then
secondsTilChange = os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=setHour, min=setMinute}) - os.time()
end
formatTable = ConvertSeconds(secondsTilChange)
formatString = formatTable.hours..' hours '..formatTable.mins..' minutes '..formatTable.secs..' seconds'
if dayState == 'SunSetToday' then
sunStateString = 'Day'
changeString = 'Sunset is in '
else
sunStateString = 'Night'
changeString = 'Sunrise is in '
end
if os.time() >= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=setHour, min=setMinute}) - 1800 and os.time() <= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=setHour, min=setMinute}) + 1800 then
sunStateString = 'Dusk'
end
if os.time() >= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=riseHour, min=riseMinute}) - 1800 and os.time() <= os.time({year=currentTime.year, month=currentTime.month, day=currentTime.day, hour=riseHour, min=riseMinute}) + 1800 then
sunStateString = 'Dawn'
end
return formatString
end
function ConvertSeconds(secondsArg)
local daysDiff = math.floor(secondsArg / 86400)
local remainder = (secondsArg % 86400)
local hoursDiff = math.floor(remainder / 3600)
local remainder = (secondsArg % 3600)
local minsDiff = math.floor(remainder / 60)
local secsDiff = (remainder % 60)
local elapsedTable = {days=daysDiff, hours=hoursDiff, mins=minsDiff, secs=secsDiff}
return elapsedTable
end