This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Weather service not working anymore?
#57
Use this:

Code:
local date = os.date('*t') local y, m, d = date.year, date.month, date.day if m < 3 then   y = y - 1   m = m + 12 end local a = math.floor(y / 100) local b = math.floor(a / 4) local c = 2 - a + b local e = math.floor(365.25 * (y + 4716)) local f = math.floor(30.6001 * (m + 1)) local jd = c + d + e + f - 1524.5 local dn = jd - 2451550.1 local nm = dn / 29.530588853 local dc = (nm % 1) * 29.530588853 local ph if dc < 1.84566 then   ph = 0 elseif dc < 5.53699 then   ph = 1 elseif dc < 9.22831 then   ph = 2 elseif dc < 12.91963 then   ph = 3 elseif dc < 16.61096 then   ph = 4 elseif dc < 20.30228 then   ph = 5 elseif dc < 23.99361 then   ph = 6 elseif dc < 27.68493 then   ph = 7 else   ph = 0 end local phases = {   [0] = 'new moon',   [1] = 'evening crescent',   [2] = 'first quarter',   [3] = 'waxing gibbous',   [4] = 'full moon',   [5] = 'waning gibbous',   [6] = 'last quarter',   [7] = 'morning crescent', } text = phases[ ph ] log(ph, text)

You can use ph number as object value and set custom values according to phases table (0..7).
Reply


Messages In This Thread
RE: Weather service not working anymore? - by admin - 03.04.2019, 07:27

Forum Jump: