Page 1 of 1

Mph to kph

Posted: September 25th, 2017, 9:47 pm
by PtitChat107
Hi,
I actively monitor volcanic and seismic activities using this skin, I would like to find a way to automatically convert the speed data of thunderstorms into kilometers per hour. I know the formula is: kph=(mph*1,60934) but could not find where to place this change in the file "StormFetch.lua" :???:

Re: Mph to kph

Posted: September 25th, 2017, 10:15 pm
by jsmorley
Change this:

Code: Select all

			if string.match(sItem, sPatternStormWind) then
				tWind[i] = string.match(sItem, sPatternStormWind)
				windSpeed = tonumber(string.match(tWind[i], '(.-) MPH'))
				tWind[i] = math.round((windSpeed * 1.60934))..' KPH'
				tMoving[i] = string.match(sItem, sPatternStormMoving)
			else
And add this at the bottom:

Code: Select all

function math.round(num, idp)
	assert(tonumber(num), 'Round expects a number.')
	
	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
1.png

Re: Mph to kph

Posted: September 26th, 2017, 8:15 am
by PtitChat107
Thank you Jsmorley, that's exactly what I wanted ! :)