It is currently September 29th, 2024, 1:28 pm

OnChangeAction fires before Substitute?

General topics related to Rainmeter.
User avatar
AlC
Posts: 329
Joined: June 9th, 2011, 6:46 pm

OnChangeAction fires before Substitute?

Post by AlC »

Hey guys,

I have a little question about OnChangeAction. Does OnChangeAction fires before the measure gets substituted?
I have this litte skin and normally it should fire every 10 minutes "why", but it fires every minute "why". In About the value stays 10 minute, it doesn't change the value however I get every minute "why".

Code: Select all

[Rainmeter]
 Update=1000

[mMinute1]
 Measure=Time
 Format="%M"
 RegExpSubstitute=1
 Substitute="([0-5])[0-9]":"\1" 
 OnChangeAction=[!Log Why]

[MeterImage]
 Meter=Image
Rainmeter - You are only limited by your imagination and creativity.
User avatar
jsmorley
Developer
Posts: 22790
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: OnChangeAction fires before Substitute?

Post by jsmorley »

As far as I am aware, Substitute does not "change" the underlying "value" of a measure it is on. The substitute is done when the value is "used" by some other element (another measure, a meter, the "Skin" log, IfCondition, IfMatch, etc.)

So the OnChangeAction is working on the actual measured value, which in the case of minutes will be once a minute.
User avatar
AlC
Posts: 329
Joined: June 9th, 2011, 6:46 pm

Re: OnChangeAction fires before Substitute?

Post by AlC »

jsmorley wrote:As far as I am aware, Substitute does not "change" the underlying "value" of a measure it is on. The substitute is done when the value is "used" by some other element (another measure, a meter, the "Skin" log, IfCondition, IfMatch, etc.)
Yes, except Lua. Lua takes the underlying value of the measure.

Code: Select all

[Rainmeter]
 Update=1000

[mMinute1]
 Measure=Time
 Format="%M"
 RegExpSubstitute=1
 Substitute="([0-5])[0-9]":"\1" 
 OnChangeAction=[!Log "OCA: The Value is [mMinute1]"]
 DynamicVariables=1

[mScriptM1]
 Measure=Script
 ScriptFile=Test.lua
 UpdateDivider=60
 
[MeterImage]
 Meter=Image

Code: Select all

function Initialize()
end

function Update()
	local Minute1 = SKIN:GetMeasure('mMinute1');
	m1 = Minute1:GetValue();
	print('LUA: Value is '..m1)
end
It was a little bit strange, because the value in About didn't changed, but the OnChangeAction fired every time.
Rainmeter - You are only limited by your imagination and creativity.