Am I right in thinking that, like with plugins, you can't use Dynamic Variables in a LUA Script? Well you can use them but they will stay at the same value you assigned to them in the [Variables] section.
Seems to me that even if you BANG them in the LUA Script with stuff like SKIN:Bang("!SetVariable MyVariable \""..WhatIreallyWant.."\"") the change will show up in the Rainmeter Meters but can not be passed back to a LUA Script in [Measure=Script] with something like My_LUA_Variable=#WhatIreallyWant#
It is currently March 28th, 2024, 7:14 pm
Use of Dynamic Variables with LUA Scripts
-
- Posts: 1167
- Joined: January 22nd, 2011, 4:23 pm
- Location: GMT +8
-
- Developer
- Posts: 2872
- Joined: April 17th, 2009, 12:18 pm
Re: Use of Dynamic Variables with LUA Scripts
Custom Setting= keys do not support dynamic variables in the SCRIPT measure. This will likely be fixed for the next beta release.
To get around this, you could use something like the following in your Update() function:
(Note that ScriptFile= does support dynamic variables)
To get around this, you could use something like the following in your Update() function:
Code: Select all
SKIN:GetVariable("WhatIreallyWant")
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Use of Dynamic Variables with LUA Scripts
Mordasius wrote:Am I right in thinking that, like with plugins, you can't use Dynamic Variables in a LUA Script? Well you can use them but they will stay at the same value you assigned to them in the [Variables] section.
Seems to me that even if you BANG them in the LUA Script with stuff like SKIN:Bang("!SetVariable MyVariable \""..WhatIreallyWant.."\"") the change will show up in the Rainmeter Meters but can not be passed back to a LUA Script in [Measure=Script] with something like My_LUA_Variable=#WhatIreallyWant#
You are correct that DynamicVariables can't be used for the optional Setting= stuff on a Lua script. However, there is an easy solution.
Just set the thing you want to pass as a "setting" as a [Variable] instead, and use GetVariable() in the Update() function of the Lua script to get the current value of that variable. Very dynamic indeed...
-
- Posts: 1167
- Joined: January 22nd, 2011, 4:23 pm
- Location: GMT +8
Re: Use of Dynamic Variables with LUA Scripts
andpoiru wrote: To get around this, you could use something like the following in your Update() function: SKIN:GetVariable("WhatIreallyWant")
I was so concerned with Setting Variables that I forgot you could also Get them from the LUA script.jsmorley wrote:.... there is an easy solution. Just set the thing you want to pass as a "setting" as a [Variable] instead, and use GetVariable() in the Initialize() or Update() function of the Lua script to get the current value of that variable. Very dynamic indeed...
As you say, very easy and very dynamic.
Thank you both.
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Use of Dynamic Variables with LUA Scripts
You are welcome.
It is one of the things that makes the Lua/Rainmeter interaction a pleasure for me. In a sense, variables are ALWAYS dynamic in a Lua script, since at any time you can use GetVariable() to find out what their current values are and use as you need.
It is one of the things that makes the Lua/Rainmeter interaction a pleasure for me. In a sense, variables are ALWAYS dynamic in a Lua script, since at any time you can use GetVariable() to find out what their current values are and use as you need.
-
- Posts: 9
- Joined: September 30th, 2011, 6:56 am
Re: Use of Dynamic Variables with LUA Scripts
If a script (eg 123.lua) change the variable in the file "var.inc"
I can get the value of this variable in another script?
write to file only option ?
PS: Sorry google translate ...
I can get the value of this variable in another script?
write to file only option ?
PS: Sorry google translate ...
-
- Posts: 1167
- Joined: January 22nd, 2011, 4:23 pm
- Location: GMT +8
Re: Use of Dynamic Variables with LUA Scripts
Yes I think you can. If your var.inc is in a folder called 'Settings', then you can use something like the following in your 123.lua script:sobaka wrote:If a script (eg 123.lua) change the variable in the file "var.inc"
I can get the value of this variable in another script? write to file only option ?
Code: Select all
sIncFilePath = SKIN:GetVariable('ROOTCONFIGPATH')
SKIN:Bang('!WriteKeyValue Variables WinPosX 500 "'..sIncFilePath..'Settings\\var.inc"')
If you are looking for something that doesn't rely on !WriteKeyValue then we'll have to wait for the experts to chime in with ideas.
-
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Use of Dynamic Variables with LUA Scripts
While you can read and write files directly in Lua, in the instance where you are setting a value in a ".ini" formatted file, like a variable in a .inc file. !WriteKeyValue is far and away the easiest way to do it, and you are going to have to refresh all skins using the .inc file (and thus the variable) in any case.
-
- Posts: 9
- Joined: September 30th, 2011, 6:56 am
Re: Use of Dynamic Variables with LUA Scripts
see example in .zip file
I do so:
1: create a file temp.txt in a folder sk2
2: add in the script sk1.lua
3:add in the script sk2.lua
4:changing the line in sk2.ini :
leftmouseupaction = !execute ["#program#""#var#"][!update]
to
leftmouseupaction = !execute ["#program#""#newvar#"][!update]
temp.txt used for transmission lines ...
This can simplify ?
would be very grateful for any response, thanks ...
PS:I make the menu "open with" for this skin http://sobaka-bim.deviantart.com/#/d4dsqbh
I do so:
1: create a file temp.txt in a folder sk2
2: add in the script sk1.lua
leftmouseupaction = !execute ["#program#""#var#"][!update]
to
leftmouseupaction = !execute ["#program#""#newvar#"][!update]
temp.txt used for transmission lines ...
This can simplify ?
would be very grateful for any response, thanks ...
PS:I make the menu "open with" for this skin http://sobaka-bim.deviantart.com/#/d4dsqbh
You do not have the required permissions to view the files attached to this post.