It is currently April 25th, 2024, 3:26 pm

Loading a skin based on weather at my location.

Get help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 16169
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Loading a skin based on weather at my location.

Post by balala »

TheIrishFrenchman wrote:yeah, that's the one. It's so widely used I assumed everyone would know what I'm talking about.
Yeah, we know.
A first solution would be the following one: open in your thext editor the dinaj.lua file within the DINAJ2 config. Locate the Update() function and modify it as you see below::

Code: Select all

function Update()
    -- get current temp
    local temp = tonumber(Handles.Temperature_Measure:GetStringValue())
    -- WebParser will not have returned values for the first few update ticks
    if temp ~= nil then
        setMeterText(Handles.Main_Meter, getMainString(temp))
        setMeterText(Handles.Sub_Meter, getSubString(temp, Settings.Unit))
	if getMainString(temp) == 'You need a jacket' then
		SKIN:Bang('!ActivateConfig', 'Rain', 'Rain.ini')
	else
		SKIN:Bang('!DeactivateConfig', 'Rain')
	end
    end
end
This will work only if you've installed the Rain skin to the default location (which I hope you did).
The disadvantage of this approach is that the rain will be activated only when the main skin returns the "You need a jacket" string. For any other returned string, the Rain won't be activated. I'm not sure what else the main skin, through the dinaj.lua can return, I didn't investigat it, but if in the future you find any other string which should activate the rain, please come back and let me (us) know, to can modify again the Update() function accordingly.
TheIrishFrenchman
Posts: 6
Joined: October 5th, 2017, 6:25 pm

Re: Loading a skin based on weather at my location.

Post by TheIrishFrenchman »

Thanks! so how can I duplicate this for a snow skin I have? I can't tell exactly what the function is getting to decide if it's raining or not.
User avatar
balala
Rainmeter Sage
Posts: 16169
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Loading a skin based on weather at my location.

Post by balala »

TheIrishFrenchman wrote:so how can I duplicate this for a snow skin I have? I can't tell exactly what the function is getting to decide if it's raining or not.
Theoretically you should add further if conditions on the above Update() function. But the problem is that, at least if I'm not mistaken, the DINAJ skin doesn1t returns the precise weather condition, just the "You need a jacket" or something like You don't need a jacket. It can't return something like It's snowing or some similar string, which could be used to activate the Snow skin. At least this is what I know. Sorry if I'm wrong...
If you can find certain string which could be used when the Snow skin should be activated, just add a second if to the Update() function:

Code: Select all

if getMainString(temp) == 'You need a jacket' then
      SKIN:Bang('!DeactivateConfig', 'Snow')
      SKIN:Bang('!ActivateConfig', 'Rain', 'Rain.ini')
elseif getMainString(temp) == 'It's snowing' then
      SKIN:Bang('!DeactivateConfig', 'Rain')
      SKIN:Bang('!ActivateConfig', 'Snow', 'Snow.ini')
else
      SKIN:Bang('!DeactivateConfig', 'Rain')
      SKIN:Bang('!DeactivateConfig', 'Snow')
end
This assuming the .ini file of the skin which should be activated when it's snowing is the Snow.ini, placed into the Snow config. Obviously if you have that skin into another config and / or is named otherwise, you have to modify the above bangs accordingly. Also if there is something else returned when it's snowing, replace the It's snowing string in the elseif statement.
But as I said, I think this skin is not a good one for such tasks. I'd propose you to use another skin, which shouldn't even use a lua script as this one does and which would be much easier to be used.
Cloudlight
Posts: 1
Joined: October 27th, 2017, 12:07 am

Re: Loading a skin based on weather at my location.

Post by Cloudlight »

What skin would you suggest? I've been trying to find one that would work easily with the provided code and i'm not sure what to look for.
User avatar
balala
Rainmeter Sage
Posts: 16169
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Loading a skin based on weather at my location.

Post by balala »

Cloudlight wrote:What skin would you suggest? I've been trying to find one that would work easily with the provided code and i'm not sure what to look for.
Try jsmorley's WXDataWeather 2.1: https://jsmorley.deviantart.com/art/WXDataWeather-2-1-603776448
If you do do, you have to add the following options to the [CurrentIconChild] measure (beside the existing ones):

Code: Select all

IfCondition=((#CURRENTSECTION#<=4)||(#CURRENTSECTION#=9)||(#CURRENTSECTION#=11)||(#CURRENTSECTION#=12)||(#CURRENTSECTION#=38)||(#CURRENTSECTION#=39)||(#CURRENTSECTION#=40)||(#CURRENTSECTION#=45)||(#CURRENTSECTION#=47))
IfTrueAction=[!DeactivateConfig "Snow"][!ActivateConfig "Rain" "Rain.ini"]
IfCondition2=(((#CURRENTSECTION#>=5)&&(#CURRENTSECTION#<=8))||(#CURRENTSECTION#=10)||(#CURRENTSECTION#=14)||((#CURRENTSECTION#>=16)&&(#CURRENTSECTION#<=18))||(#CURRENTSECTION#=25)||(#CURRENTSECTION#=35)||((#CURRENTSECTION#>=41)&&(#CURRENTSECTION#<=43))||(#CURRENTSECTION#=46))
IfTrueAction2=[!ActivateConfig "Snow" "Snow.ini"][!DeactivateConfig "Rain"]
IfCondition3=((#CURRENTSECTION#=13)||(#CURRENTSECTION#=15)||((#CURRENTSECTION#>=19)&&(#CURRENTSECTION#<=24))||((#CURRENTSECTION#>=26)&&(#CURRENTSECTION#<=34))||((#CURRENTSECTION#>=36)&&(#CURRENTSECTION#<=37))||(#CURRENTSECTION#=42)||(#CURRENTSECTION#>=44))
IfTrueAction3=[!DeactivateConfig "Snow"][!DeactivateConfig "Rain"]
(I hope I didn't mess up the conditions - check them however)
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Loading a skin based on weather at my location.

Post by jsmorley »

Given the the current conditions can change at any time from any one to any other, I would be tempted to put a "Group" name in the [Rainmeter] section of each skin, and use !DeactivateGroup "GroupName" each time I activated any of them. That way you are sure all the "others" are closed before you open one.