@ -6,14 +6,14 @@
<!-- Plugin "Aardwolf_Clock" generated by Plugin Wizard -->
<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.8 4">
<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>
<!-- 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>
</triggers>
@ -42,6 +42,9 @@
<script >
< ![CDATA[
require 'movewindow'
require 'themed_miniwindows'
async_ok, async = pcall (require, "async")
clock_seasons = {
Sun = {138, 3, 19, 1, "Light"},
@ -91,16 +94,14 @@
clock_current = {Season = "Sun", day = 1, order = 1}
local win = "AardClock_" .. GetPluginID()
local font = "f"
windowinfo = movewindow.install(win, 7, miniwin.create_absolute_location, true, nil)
win = "AardClock_Crowley"
font = "f"
checked_time = false
local footer_text = {}
footer_text = {}
local font_families = utils.getfontfamilies()
font_families = utils.getfontfamilies()
if font_families["Monoid"] then
font_name = "Monoid"
font_size = 8
@ -115,25 +116,37 @@
font_size = 10
end
WindowCreate(win, 0, 0, 0, 0, 1, 0, 0)
clockWin = ThemedBasicWindow(
win, -- id
0, -- default_left_position
0, -- default_top_position
0, -- default_width
0, -- default_height
"AardClock", -- title
"center", -- title alignment
false, -- is_temporary
1, -- resizer_type
nil, -- do_while_resizing
nil, -- do_after_resizing
nil, -- do_on_delete
fontName, -- title_font_name
fontSize, -- title_font_size
true -- defer_showing
)
require 'tprint'
--tprint(clockWin)
WindowFont(win, font, clockWin.title_font_name, clockWin.title_font_size, true)
title_height = WindowFontInfo(win, font, 1) + 5
WindowFont(win, font, font_name, font_size, true)
local font_height = WindowFontInfo(win, font, 1)
local font_width = WindowTextWidth(win, font, " ", 1)
font_height = WindowFontInfo(win, font, 1)
font_width = WindowTextWidth(win, font, " ", 1)
window_width = (20 * font_width) + 11
local cx = math.floor((window_width-5)/2) + 3
local cy = cx + font_height
bgDay = 'khaki'
bgNight = 'navy'
textDay = 'black'
textNight = 'white'
hourTime = 12
bgColour = 'khaki'
textColour = 'black'
handDay = 'black'
handNight = 'yellow'
handColour = 'black'
cx = math.floor((window_width-5)/2) + 3
cy = cx + font_height + title_height
function round(v)
local r = 0
@ -171,6 +184,32 @@
return {posx = x - offset, posy = y}
end
PLUGIN_VERSION = GetPluginInfo(GetPluginID(), 19)
PLUGIN_NAME = GetPluginInfo(GetPluginID(), 1)
clock_numbers = {}
for i = 1,12 do
table.insert(clock_numbers, {text = i, pos = findPos(i)})
end
endy = clock_numbers[6].pos.posy
starty = clock_numbers[12].pos.posy
window_height = font_height + title_height + 5 + endy + starty + (font_height * (#footer_text + 2)) -- font_height * 10
clockWin:resize(window_width, window_height)
bgDay = 'khaki'
bgNight = 'navy'
textDay = 'black'
textNight = 'white'
hourTime = 12
bgColour = 'khaki'
textColour = 'black'
handDay = 'black'
handNight = 'yellow'
handColour = 'black'
function drawHand(t, r, subset)
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
@ -200,19 +239,20 @@
end
function drawFace()
clockWin:blank()
WindowDrawImage(win, "background", 0, 0, (WindowInfo(win, 3) or 0), (WindowInfo(win, 4) or 0), miniwin.image_stretch)
local x = 5
local y = clock_numbers[6].pos.posy + font_height * 2
local y = clock_numbers[6].pos.posy + title_height + font_height * 2
WindowText(win, font, seasonEnd, center(seasonEnd), font_height/2, 0, 0, ColourNameToRGB(textColour))
WindowText(win, font, seasonEnd, center(seasonEnd), font_height/2 + title_height , 0, 0, ColourNameToRGB(textColour))
local sunr = (clock_seasons[clock_current.Season][2] or 1) .. "am"
local suns = ((tonumber(clock_seasons[clock_current.Season][3]) - 12) or 12) .. "pm"
WindowText(win, font, sunr, x, font_height*1.5, 0, 0, ColourNameToRGB(textColour))
WindowText(win, font, sunr, x, title_height + font_height*1.5, 0, 0, ColourNameToRGB(textColour))
local cdiml, cdimt = font_width, font_height*2.5
local cdiml, cdimt = font_width, title_height + font_height*2.5
local cdimr, cdimb = cdiml + font_width*2, cdimt + (font_width*2)
WindowCircleOp(win, 1, cdiml, cdimt, cdimr, cdimb, ColourNameToRGB("yellow"), 2, 1, ColourNameToRGB("yellow"), 0)
@ -220,7 +260,7 @@
cdiml = (WindowInfo(win, 3) - 5) - font_width*3
cdimr = cdiml + font_width*2
WindowText(win, font, suns, ((WindowInfo(win, 3) -5) - font_width*4), font_height*1.5, 0, 0, ColourNameToRGB(textColour))
WindowText(win, font, suns, ((WindowInfo(win, 3) -5) - font_width*4), title_height + font_height*1.5, 0, 0, ColourNameToRGB(textColour))
WindowCircleOp(win, 1, cdiml, cdimt, cdimr, cdimb, ColourNameToRGB("orangered"), 2, 1, ColourNameToRGB("orangered"), 0)
@ -242,7 +282,6 @@
for _,v in ipairs(clock_numbers) do
WindowText(win, font, v.text, v.pos.posx, v.pos.posy, 0, 0, ColourNameToRGB(textColour))
end
WindowText(win, font, (dTime or ""), center((dTime or "")), y, 0, 0, ColourNameToRGB(textColour))
@ -253,10 +292,10 @@
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))
WindowRectOp(win, 4, 1, 1, WindowInfo(win, 3)-1, WindowInfo(win, 4)-1, ColourNameToRGB("black"), ColourNameToRGB("black")) -- 9, 15 + 0x1000 + 0x4000)
WindowSetZOrder(win, 50)
WindowShow(win, true)
clockWin:dress_window()
Redraw()
end
function center(t)
@ -356,6 +395,7 @@
checked_time = true
EnableTrigger("GetTime", false)
clockWin:show()
end
function updateTime()
@ -371,6 +411,7 @@
local rH, rM = math.floor(mins_left/60), math.floor(mins_left%60)
seasonEnd = seasonEnd .. rH .. "h " .. rM .. "m"
--clockWin.title = seasonEnd
end
function onTimer()
@ -378,10 +419,12 @@
last_tick = last_tick or os.clock()
local s = os.clock() - last_tick
updateTime()
clockWin:blank()
drawFace()
drawHand(math.min(30, s), 60, 30)
hourHandTime = hourTime + s/30
drawHand(hourHandTime, 45, 12)
--clockWin:dress_window()
Redraw()
end
end
@ -405,42 +448,9 @@
end
function OnPluginDisable()
WindowDelete(win)
end
function OnPluginSaveState()
movewindow.save_state(win)
end
function OnPluginClose()
OnPluginDisable()
end
function OnPluginInstall()
PLUGIN_VERSION = GetPluginInfo(GetPluginID(), 19)
PLUGIN_NAME = GetPluginInfo(GetPluginID(), 1)
seasonEnd = ""
clock_numbers = {}
for i = 1,12 do
table.insert(clock_numbers, {text = i, pos = findPos(i)})
end
local endy = clock_numbers[6].pos.posy
local starty = clock_numbers[12].pos.posy
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