It is currently April 5th, 2020, 3:38 am

ProgressBar Someone can help me?

Discuss the use of Lua in Script measures.
User avatar
Kaz28100
Posts: 57
Joined: May 3rd, 2012, 3:59 pm
Location: France

ProgressBar Someone can help me?

Post by Kaz28100 »

So for one of my skin i use this to make a round progress bar, but this seem to not work with spotify.
I use SpotifyPlugin from .raptor
function Initialize()
ResetInterval = SELF:GetNumberOption('ResetInterval', 10)
SafetyRange = SELF:GetNumberOption('SafetyRange', 2)
mDuration = SKIN:GetMeasure('mDuration')
mPosition = SKIN:GetMeasure('mPosition')
mState = SKIN:GetMeasure('mState')
UpdatePeriod = tonumber(SKIN:GetVariable('Update'))
Counter = -1
Fake = 0
end

function Update()
local Total = mDuration:GetValue()
local Real = mPosition:GetValue()
local State = mState:GetValue() == 1 and 1 or 0
local Stopped = mState:GetValue() == 0 and 1 or 0

Counter = (Counter + 1) % (ResetInterval * (1000/UpdatePeriod))

if Stopped == 1 then
return 0
elseif Counter == 0 or math.abs(Fake-Real)>SafetyRange then
Fake = Real
else
Fake = Fake + State * (UpdatePeriod/1000)
end

return Fake / Total
end

--by Kaelri (Kaelri@gmail.com)
A comparative screenshot
You do not have the required permissions to view the files attached to this post.