I have a script to return a number based on formula, it takes 2 variables and returns 1
How do I implement a script to take 2 variables and return 1 for the skin to use inside the rainmeter skin. and how do I pull and return the variables inside the Lua script?
[measureA]
Measure=Time
Format=%a
[measureB]
Measure=Time
Format=%d
[MeasureScript]
Measure=Script
ScriptFile=script.lua
varInputA=measureA
varInputB=measureB
varReturn=return
[Meter]
X=varReturn
----LUA
varInputA="";
varInputB="";
varReturn="";
if some > comparison then
varReturn = varInputA + varInputB;
end
It is currently May 4th, 2024, 1:06 pm
Using lua?
-
- Posts: 64
- Joined: July 21st, 2010, 3:30 am
-
- Rainmeter Sage
- Posts: 16198
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Using lua?
To get a variable from a skin to a lua script, first you have to add a script measure to the skin:
Then on the lua script, use this command:
latit = tonumber(SKIN:GetVariable('Latitude'))
Here Latitude is the variable used in your skin, while latit is its corespondence in the lua script. The tonumber function converts a string to a number. If you don't use it, the variable will be used as a string and will generate errors (the script won't work).
After that you make all your calculations and send back the result to the skin, using this command:
SKIN:Bang('!SetVariable', 'VarInSkin', ResultOfTheCalculations)
Or, depending on what this result is used for, you can use a SetOption bang:
SKIN:Bang('!SetOption', 'SectionName', 'Option', ResultOfTheCalculations)
For details you can read the manual.
Be careful, lua is case sensitive: Var, VAR and var are three diferent variables.
Code: Select all
[MeasureLuaScript]
Measure=Script
ScriptFile=#@#YourLua.lua
latit = tonumber(SKIN:GetVariable('Latitude'))
Here Latitude is the variable used in your skin, while latit is its corespondence in the lua script. The tonumber function converts a string to a number. If you don't use it, the variable will be used as a string and will generate errors (the script won't work).
After that you make all your calculations and send back the result to the skin, using this command:
SKIN:Bang('!SetVariable', 'VarInSkin', ResultOfTheCalculations)
Or, depending on what this result is used for, you can use a SetOption bang:
SKIN:Bang('!SetOption', 'SectionName', 'Option', ResultOfTheCalculations)
For details you can read the manual.
Be careful, lua is case sensitive: Var, VAR and var are three diferent variables.