aboutsummaryrefslogtreecommitdiff
path: root/weather.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2009-10-04 00:54:27 +0200
committerAdrian C. (anrxc) <anrxc@sysphere.org>2009-10-04 00:54:27 +0200
commitb4e028b21ffb5b8ee384516626345cf8150dcc02 (patch)
tree389b6d74effbf63ece80661f11ed83f32f439a7e /weather.lua
parentb65d5093803ec81f89f286c90807a44fa219c733 (diff)
downloadvicious-legacy-b4e028b21ffb5b8ee384516626345cf8150dcc02.tar.xz
Removed some useless else statements
Diffstat (limited to 'weather.lua')
-rw-r--r--weather.lua48
1 files changed, 23 insertions, 25 deletions
diff --git a/weather.lua b/weather.lua
index b612955..b5c4237 100644
--- a/weather.lua
+++ b/weather.lua
@@ -41,32 +41,30 @@ local function worker(format, station)
}
-- Check if there was a timeout or a problem with the station
- if ws == nil then
- return weather
- else
- weather["{city}"] = -- City and/or area
- string.match(ws, "^(.+)%,.*%([%u]+%)") or weather["{city}"]
- weather["{wind}"] = -- Wind direction and degrees if available
- string.match(ws, "Wind:[%s][%a]+[%s][%a]+[%s](.+)[%s]at.+$") or weather["{wind}"]
- weather["{windmph}"] = -- Wind speed in MPH if available
- string.match(ws, "Wind:[%s].+[%s]at[%s]([%d]+)[%s]MPH") or weather["{windmph}"]
- weather["{sky}"] = -- Sky conditions if available
- string.match(ws, "Sky[%s]conditions:[%s](.-)[%c]") or weather["{sky}"]
- weather["{weather}"] = -- Weather conditions if available
- string.match(ws, "Weather:[%s](.-)[%c]") or weather["{weather}"]
- weather["{tempf}"] = -- Temperature in fahrenheit
- string.match(ws, "Temperature:[%s]([%d%.]+).*[%c]") or weather["{tempf}"]
- weather["{tempc}"] = -- Temperature in celsius
- string.match(ws, "Temperature:[%s][%d%.]+[%s]F[%s]%(([%d%.]+)[%s]C%)[%c]") or weather["{tempc}"]
- weather["{humid}"] = -- Relative humidity in percent
- string.match(ws, "Relative[%s]Humidity:[%s]([%d]+)%%") or weather["{humid}"]
- weather["{press}"] = -- Pressure in hPa
- string.match(ws, "Pressure[%s].+%((.+)[%s]hPa%)") or weather["{press}"]
+ if ws == nil then return weather end
- -- Wind speed in KMH if MPH was available
- if weather["{windmph}"] ~= "N/A" then
- weather["{windkmh}"] = math.floor(weather["{windmph}"] * 1.6)
- end
+ weather["{city}"] = -- City and/or area
+ string.match(ws, "^(.+)%,.*%([%u]+%)") or weather["{city}"]
+ weather["{wind}"] = -- Wind direction and degrees if available
+ string.match(ws, "Wind:[%s][%a]+[%s][%a]+[%s](.+)[%s]at.+$") or weather["{wind}"]
+ weather["{windmph}"] = -- Wind speed in MPH if available
+ string.match(ws, "Wind:[%s].+[%s]at[%s]([%d]+)[%s]MPH") or weather["{windmph}"]
+ weather["{sky}"] = -- Sky conditions if available
+ string.match(ws, "Sky[%s]conditions:[%s](.-)[%c]") or weather["{sky}"]
+ weather["{weather}"] = -- Weather conditions if available
+ string.match(ws, "Weather:[%s](.-)[%c]") or weather["{weather}"]
+ weather["{tempf}"] = -- Temperature in fahrenheit
+ string.match(ws, "Temperature:[%s]([%d%.]+).*[%c]") or weather["{tempf}"]
+ weather["{tempc}"] = -- Temperature in celsius
+ string.match(ws, "Temperature:[%s][%d%.]+[%s]F[%s]%(([%d%.]+)[%s]C%)[%c]") or weather["{tempc}"]
+ weather["{humid}"] = -- Relative humidity in percent
+ string.match(ws, "Relative[%s]Humidity:[%s]([%d]+)%%") or weather["{humid}"]
+ weather["{press}"] = -- Pressure in hPa
+ string.match(ws, "Pressure[%s].+%((.+)[%s]hPa%)") or weather["{press}"]
+
+ -- Wind speed in KMH if MPH was available
+ if weather["{windmph}"] ~= "N/A" then
+ weather["{windkmh}"] = math.floor(weather["{windmph}"] * 1.6)
end
return weather