Finally here is a first code on how to apply a lua script to calculate the color components of the Bar meter.
First create a Script.lua file into the @Resources folder of your config (obviously you can name this file as you want, just make sure to use the proper name into the below Rainmeter code). Add the following code to this file:Obviously in this code the red component of the color code will be calculated by the Red function, the green component by the Green function and as you probably figured out, the blue component by the Blue function. The only parameter of all these functions is the temperature (see below how these functions are called into the code of the skin).
Having this file, add the following Script measure to the code of your skin:Here you have to take care to use the proper file name if you've created your file with another name than Script.lua (according to what I said above). The name of the above measure can be other than [MeasureLuaScript] as well, just take care to use the same measure name in the bellow BarColor option.
If you did all this, the BarColor option of the [mt_Thermometer] meter will look this way (replace the old option): BarColor=[&MeasureLuaScript:Red([&m_0Temp])],[&MeasureLuaScript:Green([&m_0Temp])],[&MeasureLuaScript:Blue([&m_0Temp])]. Make sure the [mt_Thermometer] meter still have the DynamicVariables=1 option, otherwise the color of the bar won't be set properly.
Did you get it working this way?
First create a Script.lua file into the @Resources folder of your config (obviously you can name this file as you want, just make sure to use the proper name into the below Rainmeter code). Add the following code to this file:
Code:
function Initialize()TMin, TMax = tonumber(SKIN:GetVariable('TempMin')), tonumber(SKIN:GetVariable('TempMax'))TRange = TMax - TMinTDiv = ( TRange / 4 )TTRGB=( 255 / TDiv )RMinD=( 2 * TDiv )RMaxD=( 3 * TDiv )GMinD=( 0 * TDiv )GMaxD=( 4 * TDiv )BMinD=( 2 * TDiv )BMaxD=( 1 * TDiv )endfunction Clamp(number, Min, Max)if number < Min then return Min endif number > Max then return Max endreturn numberendfunction Red(Temp)return ( TTRGB * ( Clamp ( Temp, RMinD, RMaxD ) - RMinD ))endfunction Green(Temp)if Temp <= RMaxD thenBrt = Clamp( Temp, GMinD, BMaxD ) - GMinDelseBrt = TDiv - ( Clamp ( Temp, RMaxD, GMaxD ) - RMaxD )endreturn ( TTRGB * Brt )endfunction Blue(Temp)return ( TTRGB * ( TDiv - ( Clamp ( Temp, BMaxD, BMinD ) - BMaxD )))end
Having this file, add the following Script measure to the code of your skin:
Code:
[MeasureLuaScript]Measure=ScriptScriptFile=#@#Script.luaDisabled=1
If you did all this, the BarColor option of the [mt_Thermometer] meter will look this way (replace the old option): BarColor=[&MeasureLuaScript:Red([&m_0Temp])],[&MeasureLuaScript:Green([&m_0Temp])],[&MeasureLuaScript:Blue([&m_0Temp])]. Make sure the [mt_Thermometer] meter still have the DynamicVariables=1 option, otherwise the color of the bar won't be set properly.
Did you get it working this way?
Statistics: Posted by balala — Yesterday, 6:54 pm