PROPERTIES = {}
-- Prefixes, not a part of the syntax:
-- s(string)
-- i(integer/number)
-- ms(measure)
-- mt(meter)
-- t(table)
function Initialize()
msPowerPercent = SKIN:GetMeasure("mPowerPercent")
msPowerSource = SKIN:GetMeasure("mPowerSource")
meter1 = SKIN:GetMeter("meterBGIcon7")
meter2 = SKIN:GetMeter("meterBattGraph")
end
function Update()
iPowerPercent = msPowerPercent:GetValue()
sPowerSource = msPowerSource:GetStringValue()
if sPowerSource == "Battery" then
if iPowerPercent <= 10 then
meter1:Bang("!SetVariable ImageName BatteryOut.png")
else
meter1:Bang("!SetVariable ImageName Battery.png")
end
else
meter1:Bang("!SetVariable ImageName BatteryPlug.png")
end
meter1:Bang("!Refresh")
if iPowerPercent <=10 then meter2:Bang("!SetVariable BarColor 0,92,0,255")
elseif iPowerPercent <=30 then meter2:Bang("!SetVariable BarColor 92,0,0,255")
elseif iPowerPercent <=50 then meter2:Bang("!SetVariable BarColor 0,0,92,255")
elseif iPowerPercent <=70 then meter2:Bang("!SetVariable BarColor 11,92,0,255")
elseif iPowerPercent <=90 then meter2:Bang("!SetVariable BarColor 0,92,11,255")
else meter2:Bang("!SetVariable BarColor 125,92,48,255")
end
meter2:Bang("!Refresh")
return iPowerPercent
end
The error is called on line 30, that would be meter1:Bang("!SetVariable ImageName BatteryPlug.png") (which is the line the script should come to with the current measures in my skin).
What did i do wrong?
(Running rainmeter 2.20 r1116 64bit)
Last edited by Nooby4Ever on January 14th, 2012, 11:40 am, edited 2 times in total.
The correct usage is: SKIN:Bang('!SetVariable ImageName BatteryPlug.png')
If you're trying to change the ImageName of meterBGIcon7, then it's: SKIN:Bang('!SetOption meterBGIcon7 ImageName BatteryPlug.png')
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
smurfier wrote:The Bang command does not work that way.
The correct usage is: SKIN:Bang('!SetVariable ImageName BatteryPlug.png')
If you're trying to change the ImageName of meterBGIcon7, then it's: SKIN:Bang('!SetOption meterBGIcon7 ImageName BatteryPlug.png')
Indeed that was my intention, thanks.
So just to make sure i get it right, SKIN is a static variable initilized by "rainmeter" itself that hold the current skin name/path/whatever.
I see were i gone wrong , i got this from the website:
Nooby4Ever wrote:
Indeed that was my intention, thanks.
So just to make sure i get it right, SKIN is a static variable initilized by "rainmeter" itself that hold the current skin name/path/whatever.
I see were i gone wrong , i got this from the website:
But (now i saw it again) it indeed doesn't work for Bangs Should have found this out myself, and i had used " instad of '
Without delving too deep into the innards of how Lua works under the covers, It probably isn't good to think of SKIN as a "variable" in this case (or anyMeter in the example either for that matter) as they really are not. They are more like "objects" and the things after the ":" (like SKIN:Bang() or anyMeter:SetX()) are more like "methods". The SKIN object does indeed represent the skin that called the lua script, but be careful not to try to use it like a variable, you will just get some "handle" to the object.
Ok thanks for the explaination (my word choice was indeed not very good, not that i knew it's an "object", i ment more a sort of sytax word as print but without doing something just pointing to the skin)
Nooby4Ever wrote:Ok thanks for the explaination (my word choice was indeed not very good, not that i knew it's an "object", i ment more a sort of sytax word as print but without doing something just pointing to the skin)
Fair enough, and my syntax is not meant to be technically literally correct either. I just wanted to point out that at least for me, thinking of those things as objects and methods for those objects helps me keep what is going on a bit clearer in my own head. It is sorta consistent with how the real geeks (I exclude myself) describe "object oriented" in the context of Lua.