It is currently April 24th, 2024, 3:20 pm

Meter:SetH() not working? [Resolved]

Discuss the use of Lua in Script measures.
FlyingHyrax
Posts: 232
Joined: July 1st, 2011, 1:32 am
Location: US

Meter:SetH() not working? [Resolved]

Post by FlyingHyrax »

Update
I still have no idea what the issue was, but I tried SetH() again in a more recent version of my script and it appears to be working just fine. My bad for the false alarm.

----------------------------------------------------------------------------------------

Greetings,

While working on this skin, I had trouble getting the meter:SetY() and SetH() functions to work. I got around it initially by just using SKIN:Bang('!SetOption '....) in place of both, but when I played around with it some more I found that SetY() worked just fine - it was only SetH() that wouldn't play nice.

This works as expected:

Code: Select all

	SKIN:Bang('!SetOption ' .. Meters[i]:GetName() .. ' H ' .. h)
--	Meters[i]:SetH(h)
	Meters[i]:SetY(y)
This doesn't work - it appears like the H was set to zero for all the meters:

Code: Select all

--	SKIN:Bang('!SetOption ' .. Meters[i]:GetName() .. ' H ' .. h)
	Meters[i]:SetH(h)
	Meters[i]:SetY(y)
Any insights?
Obviously I can get the skin to work regardless, I'm just curious why one would work and the other wouldn't. I can't see how the trouble is with my 'h' variable in the function, since plugging that variable into a !SetOption bang works just fine. I also thought that maybe SetH() wouldn't work if my meters didn't already have a H=... key, but I checked and they all do (more specifically, the MeterStyle used for the all the meters in question has an H key). So I wonder...

Full script code (the trouble is in the updateHeight() function)

Code: Select all

Meters = {}
Values = {}
numBars = _
height = _
measure = _

function Initialize()
	numBars = SELF:GetNumberOption('Bars')
	height = SELF:GetNumberOption('Height')
	measure = SKIN:GetMeasure('mCPU')
	print(numBars .. ' | ' ..height)
	for i=1,numBars do
		Meters[i] = makeMeter(i)
		Values[i] = 0
	end
end

function Update()
	moveValues(measure:GetRelativeValue())
	updateHeight()
	
	return
end

function makeMeter(n)
	SKIN:Bang('!WriteKeyValue',n,'Meter','IMAGE')
	SKIN:Bang('!WriteKeyValue',n,'MeterStyle','sBar')
	meter = SKIN:GetMeter(n)
	return meter
end

function updateHeight()
	for i=1,numBars do
		h = (Values[i])*height
		h = math.floor(h)
		y = height - h
--		print(h .. ' | ' .. y)
--		SKIN:Bang('!SetOption ' .. Meters[i]:GetName() .. ' Y ' .. y)
		SKIN:Bang('!SetOption ' .. Meters[i]:GetName() .. ' H ' .. h)
--		Meters[i]:SetH(h)
		Meters[i]:SetY(y)
		

	end
end

function moveValues(newest)
	for i=1,numBars do
		Values[i] = Values[i+1]
	end
	Values[numBars] = newest
end
Rainmeter version: 2.4.0 r1678 64-bit (Nov 4 2012)
Flying Hyrax on DeviantArt