Skip to content

Instantly share code, notes, and snippets.

@meskarune
Created November 29, 2016 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save meskarune/e21517164a1aa375f8b4fa0096c03954 to your computer and use it in GitHub Desktop.
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
#!/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