Created
November 29, 2016 19:24
-
-
Save meskarune/e21517164a1aa375f8b4fa0096c03954 to your computer and use it in GitHub Desktop.
simple lua weather script, replace <API KEY> with your key from openweathermap.org
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/lua | |
-- load the http module | |
http = require("socket.http") | |
-- load the json module | |
json = require("json") | |
weather = http.request("http://api.openweathermap.org/data/2.5/weather?id=4500546&units=imperial&APPID=<API KEY>") | |
response = json.decode(weather) | |
math.round = function (n) | |
return math.floor(n + 0.5) | |
end | |
temp = response.main.temp | |
conditions = response.weather[1].main | |
io.write(math.round(temp), "°F ", conditions, "\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment