So I wrote this simple lua function since I thought it could be useful on some especial cases, but I can't get it to work for unknown reasons, since it works fine on the lua console.
It should let you input a conditional and output a string based on the result.
So this:
Prints: No
Here you can check that's true: https://onecompiler.com/lua/42vdzfkm4
The problem is that rainmeter will always return true (yes) no matter what.
Example skin:
#@#Script.lua
Test.ini
The result should be no, but it's yes.. Somehow.
I'm guessing the problem is a syntax one, so please enlighten me with your knowledge .
I already tried '10 > 18', ''10 > 18'', "10 > 18", (10 > 18), '(10 > 18)' without luck. There's also no errors on the log.
Code: Select all
function conditional(cond, true_str, false_str)
if cond then
return true_str
else
return false_str
end
end
So this:
Code: Select all
print(conditional(10 > 18, 'Yes', 'No'))
Here you can check that's true: https://onecompiler.com/lua/42vdzfkm4
The problem is that rainmeter will always return true (yes) no matter what.
Example skin:
#@#Script.lua
Code: Select all
function conditional(cond, true_str, false_str)
if cond then
return true_str
else
return false_str
end
end
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Script]
Measure=Script
ScriptFile=#@#Script.lua
UpdateDivider=-1
DynamicVariables=1
[Condition]
Measure=String
String=[&Script:conditional(10 > 18,'Yes','No')]
UpdateDivider=-1
DynamicVariables=1
[MeterResult]
Meter=String
FontFace=Consolas
FontColor=225,255,255,255
SolidColor=9,25,25,255
Padding=5,5,5,5
FontSize=18
AntiAlias=1
MeasureName=Condition
Text="Condition result: %1"
DynamicVariables=1
I'm guessing the problem is a syntax one, so please enlighten me with your knowledge .
I already tried '10 > 18', ''10 > 18'', "10 > 18", (10 > 18), '(10 > 18)' without luck. There's also no errors on the log.
Using simple lua if statements corrected by SilverAzide
Using lua string compilation (loadstring) by nek
Using ParseFormula by Crest
Any other contribution is welcome.