It is currently February 27th, 2021, 10:13 pm

TextPercent

Skins that don't neatly fit into other categories
User avatar
jsmorley
Developer
Posts: 21551
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

TextPercent

Post by jsmorley »

TextPercent_1.0.rmskin
test.gif
Skin:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=TextPercent
Author=JSMorley
Information=Converts a percentage number to a text string
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Version=Sep 17, 2015

[MeasureCPU]
Measure=CPU

[MeasureScript]
Measure=Script
ScriptFile=#CURRENTPATH#TextPercent.lua
SourceMeasure=MeasureCPU
TargetMeter=MeterCPU

[MeterCPU]
Meter=String
X=261
StringAlign=Right
FontFace=Roboto
FontSize=20
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
InlineSetting=Weight| 300
InlinePattern=.*

[MeterBar]
Meter=Bar
MeasureName=MeasureCPU
Y=2R
W=261
H=3
BarImage=#@#Images\GradientBar.jpg
SolidColor=255,255,255,255
BarOrientation=Horizontal
TextPercent.lua:

Code: Select all

function Initialize()

	measureName = SKIN:GetMeasure(SELF:GetOption('SourceMeasure'))
	meterName = SELF:GetOption('TargetMeter')

		lookupTens = {}

		lookupTens['2'] = 'twenty'
		lookupTens['3'] = 'thirty'
		lookupTens['4'] = 'forty'
		lookupTens['5'] = 'fifty'
		lookupTens['6'] = 'sixty'
		lookupTens['7'] = 'seventy'
		lookupTens['8'] = 'eighty'
		lookupTens['9'] = 'ninety'

		lookupOnes = {}

		lookupOnes['1'] = 'one'
		lookupOnes['2'] = 'two'
		lookupOnes['3'] = 'three'
		lookupOnes['4'] = 'four'
		lookupOnes['5'] = 'five'
		lookupOnes['6'] = 'six'
		lookupOnes['7'] = 'seven'
		lookupOnes['8'] = 'eight'
		lookupOnes['9'] = 'nine'
		lookupOnes['10'] = 'ten'
		lookupOnes['11'] = 'eleven'
		lookupOnes['12'] = 'twelve'
		lookupOnes['13'] = 'thirteen'
		lookupOnes['14'] = 'fourteen'
		lookupOnes['15'] = 'fifteen'
		lookupOnes['16'] = 'sixteen'
		lookupOnes['17'] = 'seventeen'
		lookupOnes['18'] = 'eighteen'
		lookupOnes['19'] = 'nineteen'

end

function Update()

	measureValue = measureName:GetStringValue()
	measureValue = tostring(Round(tonumber(measureValue),0))
	
	if measureValue == '0' then
		fullText = 'zero'
		UpdateMeter()
		return
	end
	
	if measureValue == '100' then
		fullText = 'one hundred'
		UpdateMeter()
		return
	end
	
	if tonumber(measureValue) < 20 then
		fullText = lookupOnes[measureValue]
		UpdateMeter()
		return
	end
	
	if string.match(measureValue, '.(.)') == '0' then
		fullText = lookupTens[string.match(measureValue, '(.).')]
		UpdateMeter()
		return
	end
	
	if string.match(measureValue, '.(.)') ~= '0' then
		fullText = lookupTens[string.match(measureValue, '(.).')] .. '-' .. lookupOnes[string.match(measureValue, '.(.)')]
		UpdateMeter()
		return			
	end
	
end

function UpdateMeter()

	fullText = fullText .. ' percent'
	
	SKIN:Bang('!SetOption', meterName, 'Text', fullText)
	SKIN:Bang('!UpdateMeter', meterName)
	SKIN:Bang('!Redraw')
	
	return
	
end

function Round(num, idp)
	
	local mult = 10 ^ (idp or 0)
	if num >= 0 then
		return math.floor(num * mult + 0.5) / mult
	else
		return math.ceil(num * mult - 0.5) / mult
	end
	
end
You do not have the required permissions to view the files attached to this post.