Hey,
like the title said it, how can I check if a variable was changed.
So let's say I get a variable via SKIN:GetVariable('...') and now I want to check if the value is different like the value of the previous update.
Example lua:
Var= SKIN:GetVariable('SomeVar')
if Var ~= Var(previous) then ...
Any help would be nice.
It is currently April 26th, 2024, 2:52 pm
Check if a variable was changed
-
- Posts: 329
- Joined: June 9th, 2011, 6:46 pm
Check if a variable was changed
Rainmeter - You are only limited by your imagination and creativity.
-
- Developer
- Posts: 1721
- Joined: July 25th, 2009, 4:47 am
Re: Check if a variable was changed
Here's a method I use very frequently:
Code: Select all
function Initialize()
LastValue = nil
end
function Update()
local CurrentValue = SKIN:GetVariable('SomeVar')
if CurrentValue ~= LastValue then
LastValue = CurrentValue
-- do other stuff
end
end
-
- Posts: 329
- Joined: June 9th, 2011, 6:46 pm
Re: Check if a variable was changed
Thanks Kaelri !
I had this in my mind but I couldn't strangely convert the !SetVariable-bang (from my mind) into Lua ... God!
And you should add this code with a little sentence here.
I had this in my mind but I couldn't strangely convert the !SetVariable-bang (from my mind) into Lua ... God!
And you should add this code with a little sentence here.
Rainmeter - You are only limited by your imagination and creativity.
-
- Developer
- Posts: 1721
- Joined: July 25th, 2009, 4:47 am
Re: Check if a variable was changed
Ah, good idea. :) I'd forgotten about that thread.