devomaa

World-Time Clock in ComputerCraft

May 8th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.34 KB | None | 0 0
  1. if not switchcraft then
  2.     os.loadAPI("json")
  3. end
  4. local x,y = term.getCursorPos()
  5. while true do
  6.   local obj = http.get("http://worldtimeapi.org/api/timezone/Europe/Helsinki").readAll()
  7.   local tbl = json.decode(obj)
  8.   local ts = tbl.unixtime
  9.   term.setCursorPos(x,y)
  10.   term.clearLine()
  11.   term.write(os.date('%Y-%m-%d %H:%M:%S', ts))
  12. end
Add Comment
Please, Sign In to add comment