It is currently March 28th, 2024, 2:18 pm

Dynamic Nested Variables

Get help with creating, editing & fixing problems with skins
Post Reply
past105
Posts: 13
Joined: May 7th, 2019, 6:06 am

Dynamic Nested Variables

Post by past105 »

I try to use a nested Variable and it works perfectly with static Variables. But when i change to Dynamic Variables, only the Value of the second variable is correct. the first variable is written as text.

Text=[#Key1[#lg]] will be "[#Key1<correct value var lg>"

As long as i don't change the Value of the Variable the output is correct (nesting works) as soon as i update the variable, it looks like above. So isn't it possible to work with nested dynamic variables? or is there something i missed?
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic Nested Variables

Post by balala »

Have you added the DynamicVariables=1 option to the meter?
past105
Posts: 13
Joined: May 7th, 2019, 6:06 am

Re: Dynamic Nested Variables

Post by past105 »

Yes i did. Without it works, but only with static variables. When i add the DynamicVariables=1 then it works only as long as the variable isn't update.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic Nested Variables

Post by balala »

past105 wrote: May 17th, 2019, 12:24 pm Yes i did. Without it works, but only with static variables. When i add the DynamicVariables=1 then it works only as long as the variable isn't update.
Please post the code.
past105
Posts: 13
Joined: May 7th, 2019, 6:06 am

Re: Dynamic Nested Variables

Post by past105 »

This is the code:

Code: Select all

[Rainmeter]
; This section contains general settings that can be used to change how Rainmeter behaves.
Update=1000

[Variables]
Width=200
Height=30

Key1=Key1
Key1_D="Hallo Welt"
Key1_E="Hello World"

Lg="_E"
; ----------------------------------
; STYLES are used to "centralize" options
; ----------------------------------
[StyleTitle]
StringStyle=Bold
FontColor=0,255,255,255
SolidColor=255,255,0,255
FontSize=16
AntiAlias=1

; ----------------------------------
; Measures
; ----------------------------------
[MeasureLang]
Measure=Script
ScriptFile=#CURRENTPATH#LuaTextFile.lua
FileToRead=#CURRENTPATH#ActLang
onUpdateAction=[!SetVariable Lg "[MeasureLang]"]


[MeterText]
Meter=String
MeasureName=MeasureLang
W=#Width#
H=#Height#
x=0r
y=0R
MeterStyle=StyleTitle
DynamicVariables=1
Text=[#Key[#lg]]
;-------------------------------------------------------
When i comment the onUpdateAction, then it works, but when i update it with the action, the nesting doesn't work anymore. The Lua Script reads the content from ActLang. ActLang contains same as Lg Variable (at the moment). SO i can see the correct value in the textfield.
Last edited by balala on May 17th, 2019, 3:18 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are you posting code snippets. It's the </> button.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic Nested Variables

Post by balala »

past105 wrote: May 17th, 2019, 1:56 pm When i comment the onUpdateAction, then it works, but when i update it with the action, the nesting doesn't work anymore. The Lua Script reads the content from ActLang. ActLang contains same as Lg Variable (at the moment). SO i can see the correct value in the textfield.
I can't test the code, because I don't have the code of the ActLang file (additionally still don't think omiting the extension is a good idea), but what I see is the following detail: beside the _D or _E termination, the KeyXX variables have a number as well. This is missing in your code: applying the posted code, I don't get anything working, even if I comment out the OnUpdateAction option of the [MeasureLang] measure (in a such case I get [#Key_E] on the String meter). As you can see, the number is missing.
If on the other hand I add a Num=1 variable to the [Variables] section and modify the Text option of the [MeterText] meter to Text=[#Key[#Num][#lg]], I get exactly what it's needed: Hello World.
As I said, unfortunately I can't test the code deeper, because I still don't have all needed files (like ActLang or LuaTextFile.lua - however the .lua file probably was posted once - are you the same guy as oioo?).
For a much more specific help, please pack the content of the whole config and upload the file here. This would be needed to have all needed files.
past105
Posts: 13
Joined: May 7th, 2019, 6:06 am

Re: Dynamic Nested Variables

Post by past105 »

Sorry was away during the weekend
You're right, the 1 is missing. probably i deleted it after copying it. but normaly it is there. i attached you the whole code with the lua file. I'm not Oioo, but i took the lua code from this forum. Was a bit faster than to code it again. :Whistle
So tho attachment should contain everything to start the skin and shows you what i mean.
Attachments
Test.zip
(1.27 KiB) Downloaded 16 times
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic Nested Variables

Post by balala »

past105 wrote: May 20th, 2019, 5:27 am So tho attachment should contain everything to start the skin and shows you what i mean.
Yep, I see and found that actually there is an issue in the ActLang file. The string shown by the [MeterText] meter isn't in fact [#Key1_E], but:

Code: Select all

[#Key1_E
]
with the bracket into a new line. This is caused by the fact that there is a such new line at the end of the ActLang file. This new line is taken into account, the value of the [MeasureLang] measure also has a new line character, so the nested variable isn't working as it should.
If you remove that new line, keeping just _E into its content, the code works, showing Hello World.
past105
Posts: 13
Joined: May 7th, 2019, 6:06 am

Re: Dynamic Nested Variables

Post by past105 »

What a shame. :oops: Now i understand the little line under the text. my window was just a bit too narrow to see my mistake. Thanks for your time!
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic Nested Variables

Post by balala »

Glad to help.
Post Reply