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

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

$
0
0
Hey Nek, thank you for your contribution.

Only drawback I've seen is, when using math, for example '10 + 8 = 18', it won't work. It needs the lua way: '10 + 8 == 18'

It does work fine as well though, for anyone wanting to try it, here's the example code using it:

#@#Script.lua

Code:

function conditional(cond_str, true_str, false_str)  local r = loadstring('return '..cond_str)()  return r and true_str or false_strend
Test.ini

Code:

[Rainmeter]Update=1000DynamicWindowSize=1AccurateText=1[Variables]Condition=(10 + 8)*2 == 36True=[#Condition] is TrueTrueColor=0,255,0False=[#Condition] is FalseFalseColor=255,0,0[Script]Measure=ScriptScriptFile=#@#Script.luaUpdateDivider=-1DynamicVariables=1[Condition]Measure=StringString=[&Script:conditional('[#Condition]','[#True]','[#False]')]UpdateDivider=-1DynamicVariables=1[MeterResult]Meter=StringFontFace=ConsolasFontColor=[&Script:conditional('[#Condition]','[#TrueColor]','[#FalseColor]')]SolidColor=9,25,25,255Padding=5,5,5,5FontSize=18AntiAlias=1MeasureName=ConditionText="Condition result: %1"DynamicVariables=1
Thank you both!

Statistics: Posted by RicardoTM — Yesterday, 1:48 am



Viewing all articles
Browse latest Browse all 25

Trending Articles