diff --git a/Clock.lua b/Clock.lua index 8831d74..dcdd473 100644 --- a/Clock.lua +++ b/Clock.lua @@ -3,8 +3,8 @@ ------------------------------------------- cl = {} -cl.VERSION = "0.5.10" -cl.SAV_VERSION = 0.552 +cl.VERSION = "0.6.0" +cl.SAV_VERSION = 0.6 ------------------------------------------- -- main diff --git a/Clock.txt b/Clock.txt index dc3f739..bfe3ef9 100644 --- a/Clock.txt +++ b/Clock.txt @@ -13,7 +13,7 @@ ################################### ## Title: Clock - By |c5175ea@Tyx|r -## Version 0.5.10 +## Version 0.6.0 ## Author: @Tyx ## APIVersion: 100008 ## SavedVariables: Clock_Settings diff --git a/data/gui.lua b/data/gui.lua index c80ab9f..bb9cd3a 100644 --- a/data/gui.lua +++ b/data/gui.lua @@ -394,30 +394,81 @@ local function AddMoon() name = loc.nNightF, tooltip = loc.tNightF, min = 1, - max = 25, + max = 98, step = 1, getFunc = function() return night[1] end, - setFunc = function(value) night[1] = value end + setFunc = function(value) + night[1] = value + local tmp = 100 - value + local n2 = tmp / night[2] + local n3 = tmp / night[3] + + night[2] = math.ceil(tmp / (1 + n2 / n3)) + night[3] = math.floor(tmp / (1 + n3 / n2)) + + if night[2] == 0 and night[3] == 0 then + night[2] = math.ceil(tmp / 2) + night[3] = math.floor(tmp / 2) + elseif night[2] == 0 then + night[2] = tmp - night[3] + elseif night[3] == 0 then + night[3] = tmp - night[2] + end + end }, [8] = { type = "slider", name = loc.nNightW, tooltip = loc.tNightW, min = 1, - max = 25, + max = 98, step = 1, getFunc = function() return night[2] end, - setFunc = function(value) night[2] = value end + setFunc = function(value) + night[2] = value + local tmp = 100 - value + local n1 = tmp / night[1] + local n3 = tmp / night[3] + + night[1] = math.ceil(tmp / (1 + n1 / n3)) + night[3] = math.floor(tmp / (1 + n3 / n1)) + + if night[1] == 0 and night[3] == 0 then + night[1] = math.ceil(tmp / 2) + night[3] = math.floor(tmp / 2) + elseif night[1] == 0 then + night[1] = tmp - night[3] + elseif night[3] == 0 then + night[3] = tmp - night[1] + end + end }, [9] = { type = "slider", name = loc.nNightN, tooltip = loc.tNightN, min = 1, - max = 25, + max = 98, step = 1, getFunc = function() return night[3] end, - setFunc = function(value) night[3] = value end + setFunc = function(value) + night[3] = value + local tmp = 100 - value + local n2 = tmp / night[2] + local n1 = tmp / night[1] + + night[2] = math.ceil(tmp / (1 + n2 / n1)) + night[1] = math.floor(tmp / (1 + n1 / n2)) + + if night[2] == 0 and night[1] == 0 then + night[2] = math.ceil(tmp / 2) + night[1] = math.floor(tmp / 2) + elseif night[2] == 0 then + night[2] = tmp - night[1] + elseif night[1] == 0 then + night[1] = tmp - night[2] + end + end }, [10] = { type = "button", diff --git a/data/moon.lua b/data/moon.lua index a4907ad..dd22d2a 100644 --- a/data/moon.lua +++ b/data/moon.lua @@ -5,14 +5,15 @@ cl.mn = {} local mn = cl.mn +local phaseLength = 30 ------------------ -- Phase ------------------ function mn.GetMoonPhase(osT) - local day = cl.st.GetTime("daytime") - local fullT = cl.st.GetMoon("full") * day - local wayT = cl.st.GetMoon("way") * day - local newT = cl.st.GetMoon("new") * day + local month = cl.st.GetTime("daytime") * phaseLength + local fullT = cl.st.GetMoon("full") * month / 100 + local wayT = cl.st.GetMoon("way") / 2 * month / 100 + local newT = cl.st.GetMoon("new") * month / 100 local phase = fullT + newT + wayT * 2 local start = mn.CreateFullmoon(cl.st.GetMoon("name"), cl.st.GetMoon("start")) local moon @@ -21,28 +22,28 @@ function mn.GetMoonPhase(osT) start = start + phase end - local t = osT - start + local delta = osT - start local full = fullT local waning = full + wayT local new = waning + newT local waxing = new + wayT - if full >= t then + if full >= delta then moon = "full" - t = full - t - elseif waning >= t then + delta = full - delta + elseif waning >= delta then moon = "waning" - t = waning - t - elseif new >= t then + delta = waning - delta + elseif new >= delta then moon = "new" - t = new - t + delta = new - delta else moon = "waxing" - t = waxing - t + delta = waxing - delta end - return moon, t + return moon, delta end ------------------ @@ -50,9 +51,9 @@ end ------------------ function mn.CreateFullmoon(name, t) local tSinceStart = t - local day = cl.st.GetTime("daytime") - local way = cl.st.GetMoon("way") * day - local full = cl.st.GetMoon("full") * day + local month = cl.st.GetTime("daytime") * phaseLength + local way = cl.st.GetMoon("way") / 2 * month / 100 + local full = cl.st.GetMoon("full") * month / 100 if name == "new" then tSinceStart = tSinceStart - way - full diff --git a/data/settings.lua b/data/settings.lua index 229f69a..a04fb2d 100644 --- a/data/settings.lua +++ b/data/settings.lua @@ -30,9 +30,9 @@ local defaults = { }, moon = { start = 1400340861, -- Unix time of the start of the full moon phase in s - full = 6, -- length of a full moon phase in real time in s -> TRY IN NIGHTS FOR DAYLENGTH OFFSET - new = 6, -- length of a new moon phase in real time in s - way = 10, -- length of the way between full moon and new moon in s + full = 10, -- length of a full moon phase in real time in s -> TRY IN NIGHTS FOR DAYLENGTH OFFSET + new = 10, -- length of a new moon phase in real time in s + way = 80, -- length of the way between full moon and new moon in s name = "full", }, offset = { diff --git a/data/time.lua b/data/time.lua index 1860f69..9c521f1 100644 --- a/data/time.lua +++ b/data/time.lua @@ -145,10 +145,8 @@ function tm.GetLoreDate() }, } local gameStart = CalcStartTime(1396569600) - d("GameStart: " .. tm.GetTST(gameStart)[1] .. tm.GetTST(gameStart)[2] .. tm.GetTST(gameStart)[3]) gameStart = gameStart - 4 * length.day -- 4 days before was a monday gameStart = gameStart - (30 + 28 + 31) * length.day -- 3 lore month before was the beginnung of the year when we think that 4.4 in RT is the same in Tamriel - d("GameStart2: " .. tm.GetTST(gameStart)[1] .. tm.GetTST(gameStart)[2] .. tm.GetTST(gameStart)[3]) local tSinceStart = GetTimeStamp() - gameStart length.year = length.day * 365 -- YEAR