Update Aardwolf_Clock.xml

Added new phrasing of time
master
AardCrowley 10 months ago committed by GitHub
parent d2d2eb7a60
commit f9b424faf8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -6,14 +6,14 @@
<!-- Plugin "Aardwolf_Clock" generated by Plugin Wizard --> <!-- Plugin "Aardwolf_Clock" generated by Plugin Wizard -->
<muclient> <muclient>
<plugin name="Aardwolf_Clock" author="Crowley, with help from Fiendish" id="28a36788fa20aa062e760ee2" language="Lua" purpose="Displays a realtime clock based on Aardwolf game time" save_state="y" date_written="2018-05-15 11:43:22" requires="4.90" version="2.84"> <plugin name="Aardwolf_Clock" author="Crowley, with help from Fiendish" id="28a36788fa20aa062e760ee2" language="Lua" purpose="Displays a realtime clock based on Aardwolf game time" save_state="y" date_written="2018-05-15 11:43:22" requires="4.90" version="4.00">
</plugin> </plugin>
<!-- Triggers --> <!-- Triggers -->
<triggers> <triggers>
<trigger enabled="n" match="^\s+\*\s+It is ((?:\d+|Noon|Midnight))((?:p|a))?m? on the (\d+)(?:rd|th|nd|st) day of the Season of (?:the )?(\w+).*$" script="getTime" regexp="y" sequence="100" omit_from_output="n" name="GetTime"> <trigger enabled="n" match="^\s+\*\s+It is ((?:\d+|Noon|Midnight))((?:p|a))?m? (?:in the daytime|in the evening|during the night) of the (\d+)(?:rd|th|nd|st) day of the Season of (?:the )?(\w+).*$" script="getTime" regexp="y" sequence="100" omit_from_output="n" name="GetTime">
</trigger> </trigger>
</triggers> </triggers>
@ -41,443 +41,453 @@
<script> <script>
<![CDATA[ <![CDATA[
require 'movewindow' require 'movewindow'
require 'themed_miniwindows'
clock_seasons = {
Sun = {138, 3, 19, 1, "Light"}, async_ok, async = pcall (require, "async")
Scourge = {162, 9, 18, 2, "Disease"},
River = {138, 7, 18, 3, "Water"}, clock_seasons = {
Song = {150, 6, 19, 4, "Sonic"}, Sun = {138, 3, 19, 1, "Light"},
Energy = {148, 6, 20, 5, "Energy"}, Scourge = {162, 9, 18, 2, "Disease"},
Nature = {140, 5, 19, 6, "Earth"}, River = {138, 7, 18, 3, "Water"},
Snake = {142, 5, 20, 7, "Poison"}, Song = {150, 6, 19, 4, "Sonic"},
Sword = {140, 7, 18, 8, "Slash"}, Energy = {148, 6, 20, 5, "Energy"},
Freeze = {148, 9, 19, 9, "Cold"}, Nature = {140, 5, 19, 6, "Earth"},
Thought = {148, 8, 20, 10, "Mental"}, Snake = {142, 5, 20, 7, "Poison"},
Darkness = {134, 10, 18, 11, "Shadow"}, Sword = {140, 7, 18, 8, "Slash"},
Corrosion = {136, 8, 20, 12, "Acid"}, Freeze = {148, 9, 19, 9, "Cold"},
Dagger = {120, 9, 18, 13, "Pierce"}, Thought = {148, 8, 20, 10, "Mental"},
Storm = {140, 8, 19, 14, "Electric"}, Darkness = {134, 10, 18, 11, "Shadow"},
Piety = {143, 7, 18, 15, "Holy"}, Corrosion = {136, 8, 20, 12, "Acid"},
Suffering = {135, 6, 19, 16, "Negative"}, Dagger = {120, 9, 18, 13, "Pierce"},
Burning = {144, 7, 20, 17, "Fire"}, Storm = {140, 8, 19, 14, "Electric"},
Tornado = {142, 7, 21, 18, "Air"}, Piety = {143, 7, 18, 15, "Holy"},
Stone = {120, 7, 21, 19, "Bash"}, Suffering = {135, 6, 19, 16, "Negative"},
Magi = {138, 6, 19, 20, "Magic"}, Burning = {144, 7, 20, 17, "Fire"},
} Tornado = {142, 7, 21, 18, "Air"},
Stone = {120, 7, 21, 19, "Bash"},
clock_season_order = { Magi = {138, 6, 19, 20, "Magic"},
"Sun", }
"Scourge",
"River", clock_season_order = {
"Song", "Sun",
"Energy", "Scourge",
"Nature", "River",
"Snake", "Song",
"Sword", "Energy",
"Freeze", "Nature",
"Thought", "Snake",
"Darkness", "Sword",
"Corrosion", "Freeze",
"Dagger", "Thought",
"Storm", "Darkness",
"Piety", "Corrosion",
"Suffering", "Dagger",
"Burning", "Storm",
"Tornado", "Piety",
"Stone", "Suffering",
"Magi" "Burning",
} "Tornado",
"Stone",
clock_current = {Season = "Sun", day = 1, order = 1} "Magi"
}
local win = "AardClock_" .. GetPluginID()
local font = "f" clock_current = {Season = "Sun", day = 1, order = 1}
windowinfo = movewindow.install(win, 7, miniwin.create_absolute_location, true, nil) win = "AardClock_Crowley"
font = "f"
checked_time = false
local footer_text = {} checked_time = false
footer_text = {}
local font_families = utils.getfontfamilies()
if font_families["Monoid"] then font_families = utils.getfontfamilies()
font_name = "Monoid" if font_families["Monoid"] then
font_size = 8 font_name = "Monoid"
elseif font_families["Dina"] then font_size = 8
font_name = "Dina" elseif font_families["Dina"] then
font_size = 8 font_name = "Dina"
elseif font_families["Lucida Sans Console"] then font_size = 8
font_name = "Lucida Sans Console" elseif font_families["Lucida Sans Console"] then
font_size = 10 font_name = "Lucida Sans Console"
else font_size = 10
font_name = "Consolas" else
font_size = 10 font_name = "Consolas"
end font_size = 10
end
WindowCreate(win, 0, 0, 0, 0, 1, 0, 0)
WindowFont(win, font, font_name, font_size, true) clockWin = ThemedBasicWindow(
local font_height = WindowFontInfo(win, font, 1) win, -- id
local font_width = WindowTextWidth(win, font, " ", 1) 0, -- default_left_position
0, -- default_top_position
window_width = (20 * font_width) + 11 0, -- default_width
local cx = math.floor((window_width-5)/2) + 3 0, -- default_height
local cy = cx + font_height "AardClock", -- title
"center", -- title alignment
bgDay = 'khaki' false, -- is_temporary
bgNight = 'navy' 1, -- resizer_type
textDay = 'black' nil, -- do_while_resizing
textNight = 'white' nil, -- do_after_resizing
hourTime = 12 nil, -- do_on_delete
bgColour = 'khaki' fontName, -- title_font_name
textColour = 'black' fontSize, -- title_font_size
handDay = 'black' true -- defer_showing
handNight = 'yellow' )
handColour = 'black'
require 'tprint'
function round(v) --tprint(clockWin)
local r = 0
if type(v) == 'number' then WindowFont(win, font, clockWin.title_font_name, clockWin.title_font_size, true)
i, f = math.modf(v) title_height = WindowFontInfo(win, font, 1) + 5
if f >0.5 then
r = i + 1 WindowFont(win, font, font_name, font_size, true)
else font_height = WindowFontInfo(win, font, 1)
r = i font_width = WindowTextWidth(win, font, " ", 1)
end
window_width = (20 * font_width) + 11
cx = math.floor((window_width-5)/2) + 3
cy = cx + font_height + title_height
function round(v)
local r = 0
if type(v) == 'number' then
i, f = math.modf(v)
if f >0.5 then
r = i + 1
else
r = i
end end
return r end
return r
end
function findPos(t)
local spt = 12.0
local r = 62
local offset = 0
if t > 6 then
offset = font_width
elseif t<= 6 then
offset = font_width/2
end end
function findPos(t) local a = 2 * math.pi * (spt-t) / spt
local spt = 12.0 local diff = 0.9 -- default 0.9
local r = 62
local offset = 0
if t > 6 then local s = math.sin(a)
offset = font_width local c = math.cos(a)
elseif t<= 6 then
offset = font_width/2
end
local a = 2 * math.pi * (spt-t) / spt local x = 1 + round(cx - diff * r * s)
local diff = 0.9 -- default 0.9 local y = 10 + round(cy - diff * r * c)
local s = math.sin(a) return {posx = x - offset, posy = y}
local c = math.cos(a) end
local x = 1 + round(cx - diff * r * s) PLUGIN_VERSION = GetPluginInfo(GetPluginID(), 19)
local y = 10 + round(cy - diff * r * c) PLUGIN_NAME = GetPluginInfo(GetPluginID(), 1)
return {posx = x - offset, posy = y} clock_numbers = {}
end for i = 1,12 do
table.insert(clock_numbers, {text = i, pos = findPos(i)})
end
function drawHand(t, r, subset) endy = clock_numbers[6].pos.posy
local y9, x12, y3, x6 = findPos(9), findPos(12), findPos(3), findPos(6) starty = clock_numbers[12].pos.posy
local startx, starty, endx, endy = x12.posx + (font_width)/2, y9.posy + (font_height/2), x6.posx + font_width/2, y3.posy + font_height/2 window_height = font_height + title_height + 5 + endy + starty + (font_height * (#footer_text + 2)) -- font_height * 10
local tcx = (startx + endx)/2 -- + startx
local tcy = (starty + endy)/2 -- + starty
local spt = subset
local a = 2 * math.pi * (spt-t)/ spt
local s = math.sin(a)
local c = math.cos(a)
local x1 = 1 + round(tcx + 0.1 * r * s)
local y1 = 1 + round(tcy + 0.1 * r * c)
local x2 = 1 + round(tcx - 0.9 * r * s)
local y2 = 1 + round(tcy - 0.9 * r * c)
WindowLine(win, x1, y1, x2, y2, ColourNameToRGB(handColour), miniwin.pen_solid + miniwin.pen_join_miter + miniwin.pen_endcap_round, 2)
end
function circleDraw(x, y, r)
local y9, x12, y3, x6 = findPos(9), findPos(12), findPos(3), findPos(6)
local startx, starty, endx, endy = x12.posx + (font_width)/2, y9.posy + (font_height/2), x6.posx + font_width/2, y3.posy + font_height/2
local tcx = (startx + endx)/2 -- + startx
local tcy = (starty + endy)/2 -- + starty
local left, top, right, bottom = tcx - r, tcy - r, tcx + r, tcy + r
return {l = left, t = top, r = right, b = bottom} clockWin:resize(window_width, window_height)
end
function drawFace() bgDay = 'khaki'
WindowDrawImage(win, "background", 0, 0, (WindowInfo(win, 3) or 0), (WindowInfo(win, 4) or 0), miniwin.image_stretch) bgNight = 'navy'
textDay = 'black'
textNight = 'white'
hourTime = 12
bgColour = 'khaki'
textColour = 'black'
handDay = 'black'
handNight = 'yellow'
handColour = 'black'
local x = 5 function drawHand(t, r, subset)
local y = clock_numbers[6].pos.posy + font_height * 2 local y9, x12, y3, x6 = findPos(9), findPos(12), findPos(3), findPos(6)
local startx, starty, endx, endy = x12.posx + (font_width)/2, y9.posy + (font_height/2), x6.posx + font_width/2, y3.posy + font_height/2
local tcx = (startx + endx)/2 -- + startx
local tcy = (starty + endy)/2 -- + starty
local spt = subset
local a = 2 * math.pi * (spt-t)/ spt
local s = math.sin(a)
local c = math.cos(a)
WindowText(win, font, seasonEnd, center(seasonEnd), font_height/2, 0, 0, ColourNameToRGB(textColour)) local x1 = 1 + round(tcx + 0.1 * r * s)
local y1 = 1 + round(tcy + 0.1 * r * c)
local x2 = 1 + round(tcx - 0.9 * r * s)
local y2 = 1 + round(tcy - 0.9 * r * c)
local sunr = (clock_seasons[clock_current.Season][2] or 1) .. "am" WindowLine(win, x1, y1, x2, y2, ColourNameToRGB(handColour), miniwin.pen_solid + miniwin.pen_join_miter + miniwin.pen_endcap_round, 2)
local suns = ((tonumber(clock_seasons[clock_current.Season][3]) - 12) or 12) .. "pm" end
WindowText(win, font, sunr, x, font_height*1.5, 0, 0, ColourNameToRGB(textColour)) function circleDraw(x, y, r)
local y9, x12, y3, x6 = findPos(9), findPos(12), findPos(3), findPos(6)
local startx, starty, endx, endy = x12.posx + (font_width)/2, y9.posy + (font_height/2), x6.posx + font_width/2, y3.posy + font_height/2
local tcx = (startx + endx)/2 -- + startx
local tcy = (starty + endy)/2 -- + starty
local left, top, right, bottom = tcx - r, tcy - r, tcx + r, tcy + r
local cdiml, cdimt = font_width, font_height*2.5 return {l = left, t = top, r = right, b = bottom}
local cdimr, cdimb = cdiml + font_width*2, cdimt + (font_width*2) end
WindowCircleOp(win, 1, cdiml, cdimt, cdimr, cdimb, ColourNameToRGB("yellow"), 2, 1, ColourNameToRGB("yellow"), 0) function drawFace()
clockWin:blank()
WindowDrawImage(win, "background", 0, 0, (WindowInfo(win, 3) or 0), (WindowInfo(win, 4) or 0), miniwin.image_stretch)
cdiml = (WindowInfo(win, 3) - 5) - font_width*3 local x = 5
cdimr = cdiml + font_width*2 local y = clock_numbers[6].pos.posy + title_height + font_height * 2
WindowText(win, font, suns, ((WindowInfo(win, 3) -5) - font_width*4), font_height*1.5, 0, 0, ColourNameToRGB(textColour)) WindowText(win, font, seasonEnd, center(seasonEnd), font_height/2 + title_height, 0, 0, ColourNameToRGB(textColour))
WindowCircleOp(win, 1, cdiml, cdimt, cdimr, cdimb, ColourNameToRGB("orangered"), 2, 1, ColourNameToRGB("orangered"), 0) local sunr = (clock_seasons[clock_current.Season][2] or 1) .. "am"
local suns = ((tonumber(clock_seasons[clock_current.Season][3]) - 12) or 12) .. "pm"
sqdim = circleDraw(cx, cy, 68) WindowText(win, font, sunr, x, title_height + font_height*1.5, 0, 0, ColourNameToRGB(textColour))
WindowCircleOp(win, 1, sqdim.l, sqdim.t, sqdim.r, sqdim.b, ColourNameToRGB(handColour), 0, 1, 0, 1) local cdiml, cdimt = font_width, title_height + font_height*2.5
local cdimr, cdimb = cdiml + font_width*2, cdimt + (font_width*2)
sqdim = circleDraw(cx, cy, 70) WindowCircleOp(win, 1, cdiml, cdimt, cdimr, cdimb, ColourNameToRGB("yellow"), 2, 1, ColourNameToRGB("yellow"), 0)
WindowCircleOp(win, 1, sqdim.l, sqdim.t, sqdim.r, sqdim.b, ColourNameToRGB(handColour), 0, 1, 0, 1) cdiml = (WindowInfo(win, 3) - 5) - font_width*3
cdimr = cdiml + font_width*2
sqdim = circleDraw(cx, cy, 71) WindowText(win, font, suns, ((WindowInfo(win, 3) -5) - font_width*4), title_height + font_height*1.5, 0, 0, ColourNameToRGB(textColour))
WindowCircleOp(win, 1, sqdim.l, sqdim.t, sqdim.r, sqdim.b, ColourNameToRGB(handColour), 0, 1, 0, 1) WindowCircleOp(win, 1, cdiml, cdimt, cdimr, cdimb, ColourNameToRGB("orangered"), 2, 1, ColourNameToRGB("orangered"), 0)
sqdim = circleDraw(cx, cy, 72) sqdim = circleDraw(cx, cy, 68)
WindowCircleOp(win, 1, sqdim.l, sqdim.t, sqdim.r, sqdim.b, ColourNameToRGB(handColour), 0, 1, 0, 1) WindowCircleOp(win, 1, sqdim.l, sqdim.t, sqdim.r, sqdim.b, ColourNameToRGB(handColour), 0, 1, 0, 1)
for _,v in ipairs(clock_numbers) do sqdim = circleDraw(cx, cy, 70)
WindowText(win, font, v.text, v.pos.posx, v.pos.posy, 0, 0, ColourNameToRGB(textColour))
end WindowCircleOp(win, 1, sqdim.l, sqdim.t, sqdim.r, sqdim.b, ColourNameToRGB(handColour), 0, 1, 0, 1)
WindowText(win, font, (dTime or ""), center((dTime or "")), y, 0, 0, ColourNameToRGB(textColour)) sqdim = circleDraw(cx, cy, 71)
y = y + font_height
WindowText(win, font, string.format("[ Day %d of %d ]", footer_text.Day, footer_text.Cycle), center(string.format("[ Day %d of %d ]", footer_text.Day, footer_text.Cycle)), y, 0, 0, ColourNameToRGB(textColour))
y = y + font_height
WindowText(win, font, string.format("Season of %s", footer_text.Season), center(string.format("Season of %s", footer_text.Season)), y, 0, 0, ColourNameToRGB(textColour))
y = y + font_height
WindowText(win, font, string.format("[ %s ]", footer_text.DamType), center(string.format("[ %s ]", footer_text.DamType)), y, 0, 0, ColourNameToRGB(textColour))
WindowCircleOp(win, 1, sqdim.l, sqdim.t, sqdim.r, sqdim.b, ColourNameToRGB(handColour), 0, 1, 0, 1)
WindowRectOp(win, 4, 1, 1, WindowInfo(win, 3)-1, WindowInfo(win, 4)-1, ColourNameToRGB("black"), ColourNameToRGB("black")) -- 9, 15 + 0x1000 + 0x4000) sqdim = circleDraw(cx, cy, 72)
WindowSetZOrder(win, 50)
WindowShow(win, true)
end
function center(t) WindowCircleOp(win, 1, sqdim.l, sqdim.t, sqdim.r, sqdim.b, ColourNameToRGB(handColour), 0, 1, 0, 1)
local twid = WindowTextWidth(win, font, t or 0)
local cdiff = window_width - twid
return cdiff/2 for _,v in ipairs(clock_numbers) do
WindowText(win, font, v.text, v.pos.posx, v.pos.posy, 0, 0, ColourNameToRGB(textColour))
end end
function OnPluginBroadcast (msg, id, name, text) WindowText(win, font, (dTime or ""), center((dTime or "")), y, 0, 0, ColourNameToRGB(textColour))
if (id == '3e7dedbe37e44942dd46d264') then y = y + font_height
if (text == 'comm.tick') then WindowText(win, font, string.format("[ Day %d of %d ]", footer_text.Day, footer_text.Cycle), center(string.format("[ Day %d of %d ]", footer_text.Day, footer_text.Cycle)), y, 0, 0, ColourNameToRGB(textColour))
if checked_time then y = y + font_height
if hourTime == 12 then WindowText(win, font, string.format("Season of %s", footer_text.Season), center(string.format("Season of %s", footer_text.Season)), y, 0, 0, ColourNameToRGB(textColour))
hourTime = 1 y = y + font_height
else WindowText(win, font, string.format("[ %s ]", footer_text.DamType), center(string.format("[ %s ]", footer_text.DamType)), y, 0, 0, ColourNameToRGB(textColour))
hourTime = hourTime + 1
end WindowRectOp(win, 4, 1, 1, WindowInfo(win, 3)-1, WindowInfo(win, 4)-1, ColourNameToRGB("black"), ColourNameToRGB("black")) -- 9, 15 + 0x1000 + 0x4000)
clockWin:dress_window()
if rTime == 23 then Redraw()
rTime = 0
updateDay() end
else
rTime = rTime + 1 function center(t)
end local twid = WindowTextWidth(win, font, t or 0)
local cdiff = window_width - twid
if rTime >= 12 then
dTime = hourTime .. "pm" return cdiff/2
else end
dTime = hourTime .. "am"
end function OnPluginBroadcast (msg, id, name, text)
checkColours() if (id == '3e7dedbe37e44942dd46d264') then
ResetTimer("clockTimer") if (text == 'comm.tick') then
last_tick = os.clock() if checked_time then
onTimer() if hourTime == 12 then
hourTime = 1
else else
EnableTrigger("GetTime") hourTime = hourTime + 1
Send(" time")
end end
if rTime == 23 then
rTime = 0
updateDay()
else
rTime = rTime + 1
end
if rTime >= 12 then
dTime = hourTime .. "pm"
else
dTime = hourTime .. "am"
end
checkColours()
ResetTimer("clockTimer")
last_tick = os.clock()
onTimer()
else
EnableTrigger("GetTime")
Send(" time")
end end
end end
end end
end
function OnPluginConnect() function OnPluginConnect()
checked_time = false checked_time = false
end end
function forceUpdateTime() function forceUpdateTime()
EnableTrigger("GetTime") EnableTrigger("GetTime")
Send(" time") Send(" time")
end
function checkColours()
local sunrise, sunset = clock_seasons[clock_current.Season][2], clock_seasons[clock_current.Season][3]
if rTime >= sunrise and rTime < sunset then
bgColour = bgDay
textColour = textDay
handColour = handDay
bgImage = "cloud"
elseif rTime >= sunset or rTime < sunrise then
bgColour = bgNight
textColour = textNight
handColour = handNight
sunsetColour = textColour
bgImage = "darkstone"
end end
function checkColours() WindowLoadImage(win, "background", GetInfo(66) .. "/worlds/plugins/images/" .. bgImage .. ".png")
local sunrise, sunset = clock_seasons[clock_current.Season][2], clock_seasons[clock_current.Season][3] end
if rTime >= sunrise and rTime < sunset then
bgColour = bgDay
textColour = textDay
handColour = handDay
bgImage = "cloud"
elseif rTime >= sunset or rTime < sunrise then
bgColour = bgNight
textColour = textNight
handColour = handNight
sunsetColour = textColour
bgImage = "darkstone"
end
WindowLoadImage(win, "background", GetInfo(66) .. "/worlds/plugins/images/" .. bgImage .. ".png")
end
function getTime(name, line, args) function getTime(name, line, args)
clock_current = {Season = args[4], day = tonumber(args[3]), order = clock_seasons[args[4]][4]} clock_current = {Season = args[4], day = tonumber(args[3]), order = clock_seasons[args[4]][4]}
footer_text = {Day = tonumber(args[3]), Season = args[4], Cycle = clock_seasons[args[4]][1], DamType = clock_seasons[args[4]][5]} footer_text = {Day = tonumber(args[3]), Season = args[4], Cycle = clock_seasons[args[4]][1], DamType = clock_seasons[args[4]][5]}
if args[1] == "Noon" then if args[1] == "Noon" then
hourTime = 12 hourTime = 12
rTime = 12 rTime = 12
elseif args[1] == "Midnight" then elseif args[1] == "Midnight" then
hourTime = 12 hourTime = 12
rTime = 0 rTime = 0
else
hourTime = tonumber(args[1])
if args[2] == "a" then
rTime = tonumber(args[1])
dTime = hourTime .. "am"
else else
hourTime = tonumber(args[1]) rTime = tonumber(args[1]) + 12
if args[2] == "a" then dTime = hourTime .. "pm"
rTime = tonumber(args[1])
dTime = hourTime .. "am"
else
rTime = tonumber(args[1]) + 12
dTime = hourTime .. "pm"
end
end end
end
checkColours() checkColours()
updateTime() updateTime()
checked_time = true checked_time = true
EnableTrigger("GetTime", false) EnableTrigger("GetTime", false)
end clockWin:show()
end
function updateTime() function updateTime()
seasonEnd = "Season ends: " seasonEnd = "Season ends: "
local days, hours, cday = clock_seasons[clock_current.Season][1], rTime, clock_current.day local days, hours, cday = clock_seasons[clock_current.Season][1], rTime, clock_current.day
local days_left = days - cday local days_left = days - cday
local days_mins_left = (days_left-1) * 12 local days_mins_left = (days_left-1) * 12
local day_mins_left = 24 - (rTime * 0.5) local day_mins_left = 24 - (rTime * 0.5)
local mins_left = days_mins_left + day_mins_left local mins_left = days_mins_left + day_mins_left
local rH, rM = math.floor(mins_left/60), math.floor(mins_left%60) local rH, rM = math.floor(mins_left/60), math.floor(mins_left%60)
seasonEnd = seasonEnd .. rH .. "h " .. rM .. "m" seasonEnd = seasonEnd .. rH .. "h " .. rM .. "m"
end --clockWin.title = seasonEnd
end
function onTimer() function onTimer()
if checked_time then if checked_time then
last_tick = last_tick or os.clock() last_tick = last_tick or os.clock()
local s = os.clock() - last_tick local s = os.clock() - last_tick
updateTime() updateTime()
drawFace() clockWin:blank()
drawHand(math.min(30, s), 60, 30) drawFace()
hourHandTime = hourTime + s/30 drawHand(math.min(30, s), 60, 30)
drawHand(hourHandTime, 45, 12) hourHandTime = hourTime + s/30
Redraw() drawHand(hourHandTime, 45, 12)
end --clockWin:dress_window()
Redraw()
end end
end
function updateDay()
if clock_current.day == clock_seasons[clock_current.Season][1] then function updateDay()
if clock_current.order == #clock_season_order then if clock_current.day == clock_seasons[clock_current.Season][1] then
clock_current.order = 1 if clock_current.order == #clock_season_order then
clock_current.Season = "Sun" clock_current.order = 1
clock_current.day = 1 clock_current.Season = "Sun"
else clock_current.day = 1
clock_current.order = clock_current.order + 1
clock_current.Season = clock_season_order[clock_current.order]
clock_current.day = 1
end
else else
clock_current.day = clock_current.day + 1 clock_current.order = clock_current.order + 1
clock_current.Season = clock_season_order[clock_current.order]
clock_current.day = 1
end end
else
clock_current.day = clock_current.day + 1
end
footer_text = {Day = clock_current.day, Cycle = clock_seasons[clock_current.Season][1], Season = clock_current.Season, DamType = clock_seasons[clock_current.Season][5]} footer_text = {Day = clock_current.day, Cycle = clock_seasons[clock_current.Season][1], Season = clock_current.Season, DamType = clock_seasons[clock_current.Season][5]}
end end
function OnPluginDisable() function update_plugin()
WindowDelete(win) raw = "https://raw.githubusercontent.com/AardCrowley/Aardwolf-Scripts/master/Aardwolf_Clock%20V2/Aardwolf_Clock.xml"
end
function OnPluginSaveState() if async_ok then
movewindow.save_state(win) plugin_page = async.doAsyncRemoteRequest(raw, raw_get, "HTTPS")
else
ColourNote("white", "blue", "Error on plugin update!")
end end
end
function OnPluginClose() function raw_get(retval, page, status, headers, full_status, request_url)
OnPluginDisable() if status == 200 then
raw_version = tonumber(string.match(page, '%s+version="([0-9%.]+)">'))
end end
function OnPluginInstall() if raw_version == PLUGIN_VERSION then
PLUGIN_VERSION = GetPluginInfo(GetPluginID(), 19) ColourNote("white", "blue", PLUGIN_NAME .. " is up-to-date.")
PLUGIN_NAME = GetPluginInfo(GetPluginID(), 1) elseif raw_version > PLUGIN_VERSION then
ColourNote("white", "blue", "Updating from version " .. PLUGIN_VERSION .. " to " .. raw_version .. ". Do not touch anything!")
seasonEnd = "" local file = io.open(GetPluginInfo(GetPluginID(), 6), "w")
file:write(page)
file:close()
clock_numbers = {} if "" == GetAlphaOption("script_prefix") then
for i = 1,12 do SetAlphaOption("script_prefix", "\\\\\\")
table.insert(clock_numbers, {text = i, pos = findPos(i)})
end end
local endy = clock_numbers[6].pos.posy Execute(GetAlphaOption("script_prefix") .. "DoAfterSpecial(1, \"ReloadPlugin('" .. GetPluginID() .. "')\", sendto.script)")
local starty = clock_numbers[12].pos.posy ColourNote("white", "blue", "Update complete!")
local window_height = font_height + 5 + endy + starty + (font_height * (#footer_text + 2)) -- font_height * 10
WindowCreate(win, windowinfo.window_left, windowinfo.window_top, window_width, window_height, windowinfo.window_mode, windowinfo.window_flags + miniwin.create_keep_hotspots, ColourNameToRGB("black"))
movewindow.add_drag_handler (win, 0, 0, 0, window_height)
end
function update_plugin()
raw = "https://raw.githubusercontent.com/AardCrowley/Aardwolf-Scripts/master/Aardwolf_Clock%20V2/Aardwolf_Clock.xml"
async_ok, async = pcall (require, "async")
if async_ok then
plugin_page = async.doAsyncRemoteRequest(raw, raw_get, "HTTPS")
else
ColourNote("white", "blue", "Error on plugin update!")
end
end end
function raw_get(retval, page, status, headers, full_status, request_url) raw_version = nil
if status == 200 then end -- end Update code
raw_version = tonumber(string.match(page, '%s+version="([0-9%.]+)">'))
end
if raw_version == PLUGIN_VERSION then function onHelp()
ColourNote("white", "blue", PLUGIN_NAME .. " is up-to-date.") ColourNote("orange", "", "AardClock Help (Generic until I make it better)")
elseif raw_version > PLUGIN_VERSION then ColourNote("orange", "", "aardclock time -- force an update of time, useful for disconnections and reboots")
ColourNote("white", "blue", "Updating from version " .. PLUGIN_VERSION .. " to " .. raw_version .. ". Do not touch anything!") ColourNote("orange", "", "aardclock update -- automatically update the plugin when new versions come out")
local file = io.open(GetPluginInfo(GetPluginID(), 6), "w") ColourNote("orange", "", "aardlock help -- what you're reading now...")
file:write(page) end
file:close()
if "" == GetAlphaOption("script_prefix") then
SetAlphaOption("script_prefix", "\\\\\\")
end
Execute(GetAlphaOption("script_prefix") .. "DoAfterSpecial(1, \"ReloadPlugin('" .. GetPluginID() .. "')\", sendto.script)")
ColourNote("white", "blue", "Update complete!")
end
raw_version = nil
end -- end Update code
function onHelp()
ColourNote("orange", "", "AardClock Help (Generic until I make it better)")
ColourNote("orange", "", "aardclock time -- force an update of time, useful for disconnections and reboots")
ColourNote("orange", "", "aardclock update -- automatically update the plugin when new versions come out")
ColourNote("orange", "", "aardlock help -- what you're reading now...")
end
]]> ]]>
</script> </script>

Loading…
Cancel
Save