You can use loadstring() in the Lua function. See also Brian's post
See also Dont assert() with Inline Lua by jsmorley
From 10 > 18 to '10 > 18' in the Test.ini (original post)
Rainmeter & Lua | https://docs.rainmeter.net/manual/lua-scripting/
Lua Online | https://onecompiler.com/lua/
Lua Tutorial | https://www.tutorialspoint.com/lua/
lua-users Tutorial | http://lua-users.org/wiki/TutorialDirectory
lua-users Sample Code | http://lua-users.org/wiki/SampleCode
Lua 5.1 Reference Manual | https://lua.org/manual/5.1/manual.html
Stack Overflow | https://stackoverflow.com/questions/tagged/lua?tab=Frequent
Code:
function conditional(cond_str, true_str, false_str) local r = loadstring('return '..cond_str)() -- print(type(r), r) return r and true_str or false_strend---- Lua Note: for type boolean, nil and false count as false;-- everything else is true (including 0 and "").--
From 10 > 18 to '10 > 18' in the Test.ini (original post)
Code:
[Condition]Measure=String; String=[&Script:conditional(10 > 18,'Yes','No')]String=[&Script:conditional('10 > 18','Yes','No')]UpdateDivider=-1DynamicVariables=1
Rainmeter & Lua | https://docs.rainmeter.net/manual/lua-scripting/
Lua Online | https://onecompiler.com/lua/
Lua Tutorial | https://www.tutorialspoint.com/lua/
lua-users Tutorial | http://lua-users.org/wiki/TutorialDirectory
lua-users Sample Code | http://lua-users.org/wiki/SampleCode
Lua 5.1 Reference Manual | https://lua.org/manual/5.1/manual.html
Stack Overflow | https://stackoverflow.com/questions/tagged/lua?tab=Frequent
Statistics: Posted by nek — Today, 12:03 am