Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1407

Lua Scripting • Lua for conditional operators with strings as result. [Help]

$
0
0
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.

Code:

function conditional(cond, true_str, false_str)    if cond then        return true_str    else        return false_str    endend
It should let you input a conditional and output a string based on the result.

So this:

Code:

print(conditional(10 > 18, 'Yes', 'No'))
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

Code:

function conditional(cond, true_str, false_str)if cond then        return true_str    else        return false_str    endend
Test.ini

Code:

[Rainmeter]Update=1000DynamicWindowSize=1AccurateText=1[Script]Measure=ScriptScriptFile=#@#Script.luaUpdateDivider=-1DynamicVariables=1[Condition]Measure=StringString=[&Script:conditional(10 > 18,'Yes','No')]UpdateDivider=-1DynamicVariables=1[MeterResult]Meter=StringFontFace=ConsolasFontColor=225,255,255,255SolidColor=9,25,25,255Padding=5,5,5,5FontSize=18AntiAlias=1MeasureName=ConditionText="Condition result: %1"DynamicVariables=1
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.

Statistics: Posted by RicardoTM — Yesterday, 9:36 pm



Viewing all articles
Browse latest Browse all 1407

Trending Articles