It is currently March 28th, 2024, 1:03 pm

!SetVariable not working in the Initialize function on LUA?

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
Jeff
Posts: 326
Joined: September 3rd, 2018, 11:18 am

!SetVariable not working in the Initialize function on LUA?

Post by Jeff »

As the title implies, I have a lua file with just

Code: Select all

function Initialize()
	value = 21
	SKIN:Bang('!SetVariable', 'H', value)
end
and a Rainmeter skin with just

Code: Select all

[Rainmeter]
Update=-1
[Dummy]
Meter=String
[Lua]
Measure=Script
ScriptFile=bug.lua
OnUpdateAction=!Log "#h#"
It seems like Rainmeter registers the variable in the Open Log > Skins section but trying to use it anywhere just returns the the variable name (as if it was escaped) or the number 0 (I assume that's what happens since in a Calc measure using the variable there in any math makes the Formula equal 0)
Am I stupid? !UpdateMeasure/Meter dosen't do anything either.
I also know I can make another function that is just function Oof() return value end and call it in the Initialize function or use Inline Lua, but that's beaside the point since I wanna do multiple !SetVariable in bulk
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: !SetVariable not working in the Initialize function on LUA?

Post by jsmorley »

Jeff wrote: September 25th, 2019, 7:16 pm As the title implies, I have a lua file with just

Code: Select all

function Initialize()
	value = 21
	SKIN:Bang('!SetVariable', 'H', value)
end
and a Rainmeter skin with just

Code: Select all

[Rainmeter]
Update=-1
[Dummy]
Meter=String
[Lua]
Measure=Script
ScriptFile=bug.lua
OnUpdateAction=!Log "#h#"
It seems like Rainmeter registers the variable in the Open Log > Skins section but trying to use it anywhere just returns the the variable name (as if it was escaped) or the number 0 (I assume that's what happens since in a Calc measure using the variable there in any math makes the Formula equal 0)
Am I stupid? !UpdateMeasure/Meter dosen't do anything either.
I also know I can make another function that is just function Oof() return value end and call it in the Initialize function or use Inline Lua, but that's beaside the point since I wanna do multiple !SetVariable in bulk
You need to use DynamicVariables=1 anywhere you are using a #VarName# that can be changed, or in this case, created.

Code: Select all

[Rainmeter]
Update=-1

[Dummy]
Meter=String

[Lua]
Measure=Script
ScriptFile=bug.lua
OnUpdateAction=!Log "#h#"
DynamicVariables=1

1.jpg
User avatar
Jeff
Posts: 326
Joined: September 3rd, 2018, 11:18 am

Re: !SetVariable not working in the Initialize function on LUA?

Post by Jeff »

jsmorley wrote: September 25th, 2019, 7:24 pm You need to use DynamicVariables=1 anywhere you are using a #VarName# that can be changed, or in this case, created.
I'm so dumb, thank you very much Saint Jsmorley :D
With this (and parentheses around the H and W option), my skin that sets the width and height of Honeycomb based on the Os in the name works perfectly.
Image
I'm doing this in preparation of changing the background shape into an actual shape meter instead of the horrible not aliased image that comes with all Honeycombs.
Thank you very much again!
Post Reply