It is currently July 18th, 2024, 10:42 pm

The String Meter Skin Only Displays Zero

Discuss the use of Lua in Script measures.
zIa1yBX5
Posts: 5
Joined: January 2nd, 2024, 11:55 am

The String Meter Skin Only Displays Zero

Post by zIa1yBX5 »

this is ini file

Code: Select all

```
[MeterSecondaryString]
Meter = String
Text = [Script:f---()]
FontSize = (14*#Scale#)
MeterStyle = TextStyle
X = 0R
Y = (-15*#Scale#)R
```
this is lua file

Code: Select all

```
function f---()
    return 10
end
```
Last edited by balala on January 2nd, 2024, 12:39 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are posting code snippets. It's the </> button.
User avatar
Jeff
Posts: 337
Joined: September 3rd, 2018, 11:18 am

Re: The String Meter Skin Only Displays Zero

Post by Jeff »

Image

AAAAAND you forgot a & before the Script section name, what you're trying to do seems to also be achievable with returning variables though
Last edited by Jeff on January 2nd, 2024, 12:25 pm, edited 1 time in total.
zIa1yBX5
Posts: 5
Joined: January 2nd, 2024, 11:55 am

Re: The String Meter Skin Only Displays Zero

Post by zIa1yBX5 »

Jeff wrote: January 2nd, 2024, 12:21 pm Image
idk what he was talking about so I dismiss it
User avatar
Yincognito
Rainmeter Sage
Posts: 7742
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: The String Meter Skin Only Displays Zero

Post by Yincognito »

zIa1yBX5 wrote: January 2nd, 2024, 11:59 am this is ini file

```
[MeterSecondaryString]
Meter = String
Text = [Script:f---()]
FontSize = (14*#Scale#)
MeterStyle = TextStyle
X = 0R
Y = (-15*#Scale#)R
```

this is lua file

```
function f---()
return 10
end
```
There are 3 mistakes in your codes:
- the syntax for the Lua inline measure should have an & after [, i.e. [&Script:YourFunction()], see the syntax here
- your meter should have DynamicVariables=1 added to it, to allow retrieving the values of section variables like the call to your Lua function, see the first line here
- in Lua, preceding something with -- is turning the rest of that line into a comment, so you might want to replace - with a similar character like _ instead, e.g. [&Script:f___()] in the .ini file and function f___() in the .lua file
The above assumes that you have a valid Script measure in your omitted code that points to the proper .lua file, of course.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
zIa1yBX5
Posts: 5
Joined: January 2nd, 2024, 11:55 am

Re: The String Meter Skin Only Displays Zero

Post by zIa1yBX5 »

Yincognito wrote: January 2nd, 2024, 12:26 pm There are 3 mistakes in your codes:
- the syntax for the Lua inline measure should have an & after [, i.e. [&Script:YourFunction()], see the syntax here
- your meter should have DynamicVariables=1 added to it, to allow retrieving the values of section variables like the call to your Lua function, see the first line here
- in Lua, preceding something with -- is turning the rest of that line into a comment, so you might want to replace - with a similar character like _ instead, e.g. [&Script:f___()] in the .ini file and function f___() in the .lua file
The above assumes that you have a valid Script measure in your omitted code that points to the proper .lua file, of course.
Thank u
User avatar
Yincognito
Rainmeter Sage
Posts: 7742
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: The String Meter Skin Only Displays Zero

Post by Yincognito »

zIa1yBX5 wrote: January 2nd, 2024, 12:27 pmThank u
No problem, glad to help. It's more or less what Jeff illustrated as well. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth