fix for weather.lua

This commit is contained in:
Akamaru 2015-07-26 22:00:55 +02:00
parent 08bcf80d84
commit 1e028cc823

View File

@ -4,6 +4,7 @@ local BASE_URL = "http://api.openweathermap.org/data/2.5/weather"
local function get_weather(location) local function get_weather(location)
print("Finde Wetter in ", location) print("Finde Wetter in ", location)
local location = string.gsub(location," ","+")
local url = BASE_URL local url = BASE_URL
url = url..'?q='..location url = url..'?q='..location
url = url..'&lang=de&units=metric' url = url..'&lang=de&units=metric'
@ -14,9 +15,7 @@ local function get_weather(location)
local weather = json:decode(b) local weather = json:decode(b)
local city = weather.name local city = weather.name
local country = weather.sys.country local country = weather.sys.country
local temp = 'Die Temperatur in '..city local temp = 'Die Temperatur in '..city..' (' ..country..')'..' beträgt '..weather.main.temp..'°C'
..' (' ..country..')'
..' beträgt '..weather.main.temp..'°C'
local conditions = 'Die aktuelle Wetterlage ist: ' local conditions = 'Die aktuelle Wetterlage ist: '
.. weather.weather[1].description .. weather.weather[1].description