It is currently September 17th, 2021, 1:52 pm

Am I even on the right path.

Discuss the use of Lua in Script measures.
User avatar
jsmorley
Developer
Posts: 22270
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Am I even on the right path.

Post by jsmorley »

Jkon wrote:Had to add another end function but it's working.
PROPERTIES =
{

}

function Initialize()

tImages = {}
for i = 1, 2 do
tImages = SKIN:GetMeter("Image"..i)

end

end -- function Initialize

function Update()

for i = 1, 2 do
Height = tImages:GetH()

SKIN:Bang("!SetVariable H"..i.." "..Height)

end

return tostring(Height)

end -- function Update


Also had to change the return to (Height).Not sure what the purpose of return is and what should really be in there.


Looks good. You don't really need a "return" here, you are not using the value of the script measure anywhere in the skin with "MeasureName=ScriptMeasure" on a meter or "Formula=ScriptMeasure" in a Calc. However, using return even in that case can be useful so you can glance at "About" in Rainmeter and see that things are working. You can use it for some quick debugging, by "returning" some variable you are interested in. Even just saying

return "Hey, it works!"

Can be useful, as if the script crashes, you won't get that in "About", you will get a blank.
User avatar
Jkon
Posts: 185
Joined: December 4th, 2009, 2:05 am

Re: Am I even on the right path.

Post by Jkon »

Understood.Thanks for your help again.Now I need to try to adapt the script so it will ignore a meter if it does not exist as because of the nature of the skin each image and its border are in separate includes and not all includes need be included in the ini at one time.This should be interesting,wish me luck.
Image
User avatar
jsmorley
Developer
Posts: 22270
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Am I even on the right path.

Post by jsmorley »

Jkon wrote:Understood.Thanks for your help again.Now I need to try to adapt the script so it will ignore a meter if it does not exist as because of the nature of the skin each image and its border are in separate includes and not all includes need be included in the ini at one time.This should be interesting,wish me luck.
Well, you can do a "GetMeter" and check for a "nil" return from the function.

Good luck and have fun!