It is currently February 19th, 2020, 2:51 pm

Get variable for Lua script from a separate folder

Discuss the use of Lua in Script measures.
Tenordrummer101
Posts: 1
Joined: November 18th, 2015, 2:01 am

Get variable for Lua script from a separate folder

Post by Tenordrummer101 »

I want to get the variable "MeasureWeather" from the weather.ini file and use it in a Lua script to change the background. I can write most of the code but i don't understand how to reference the variable from outside the file. Any help would be appreciated.
User avatar
balala
Rainmeter Sage
Posts: 9712
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Get variable for Lua script from a separate folder

Post by balala »

Are you sure that MeasureWeather is a variable? It's not a measure (I'm asking because of its name)? If it's a variable, in your lua script, use the SomeVariable = tonumber(SKIN:GetVariable('MeasureWeather')) (if MeasureWeather is a number and you want to use its numeric value into the lua script) or simply the SomeVariable = SKIN:GetVariable('MeasureWeather') (if it's a string variable).
But if MeasureWeather is a measure, returning a number, you should use something like:

Code: Select all

SomeVariable = SKIN:GetMeasure('MeasureWeather')
SomeVarNum = SomeVariable:GetValue()
SomeVarNum will get the numeric value of the MeasureWeather measure.
If MeasureWeather returns a string (instead of the number) use this:

Code: Select all

SomeVariable = SKIN:GetMeasure('MeasureWeather')
SomeVarString = SomeVariable:GetStringValue()