This Lua script tracks protective spells using a miniwindow.
You are affected by the following spells:
Spell: armor : modifies armor class by -20 for 24 cycles, (12 hours)
Spell: sanctuary : modifies none by 0 for 6 cycles, (3 hours)
Spell: shield : modifies armor class by -20 for 46 cycles, (23 hours)
Spell: stone skin : modifies armor class by -40 for 38 cycles, (19 hours)
A cycle is random, but the range is about 42 to 48 seconds per cycle.
A sanctuary spell lasts at minimum 6*42 seconds.
Screenshot:
http://photobucket.com/albums/ad147/moratbucket/spell.png
3, 6 or 9 o'clock means the spell is 25, 50 or 75 percent done, respectively.
The clock is white if the spell has more than 6*42*2/3 seconds to drop.
The clock is yellow if the spell has between 6*42*2/3 and 6*42*1/3 seconds to drop.
The clock is red if the spell has less than 6*42*1/3 seconds to drop.
At 12 o'clock, the timer disappears. When the spell drops, the timer and icon disappears.
I'm curious how other users are tracking their spells with miniwindows.
* Timer
Event: Every interval, 1 second
if not spell then
spell = {}
table.insert(spell, {name = "armor", cycle = 24, time = 24*42, stamp = 0})
table.insert(spell, {name = "sanctuary", cycle = 6, time = 6*42, stamp = 0})
table.insert(spell, {name = "shield", cycle = 46, time = 46*42, stamp = 0})
table.insert(spell, {name = "stone skin", cycle = 38, time = 38*42, stamp = 0})
WindowCreate("spell", -- miniwindow name
0, 0, -- left, top (ignore)
2*64, #spell*64, -- width, height
6, -- position (top right)
8, -- flags (ignore mouse)
ColourNameToRGB("black")) -- background colour
WindowLoadImage("spell", "armor", "armor.png") -- load miniwindow images (64x64 pixels)
WindowLoadImage("spell", "sanctuary", "sanctuary.png")
WindowLoadImage("spell", "shield", "shield.png")
WindowLoadImage("spell", "stone skin", "stone_skin.png")
WindowShow("spell", true) -- show miniwindow
else
for n = 1, #spell do
local countdown = spell[n].time+spell[n].stamp-os.time()
if countdown > 0 then
local pct = 1-countdown/spell[n].time -- percent usage: 0 to 1
local rgb -- circle colour: white, yellow, red
if countdown > 6*42*2/3 then
rgb = ColourNameToRGB("white") -- white: countdown > 6*42*2/3
elseif countdown < 6*42*1/3 then
rgb = ColourNameToRGB("red") -- red: countdown < 6*42*1/3
else
rgb = ColourNameToRGB("yellow")
end
WindowRectOp("spell", -- miniwindow name
2, -- action (fill rectangle with colour 1)
0, (n-1)*64, 1*64, n*64, -- left, top, right, bottom
ColourNameToRGB("black"), -- colour 1
0) -- colour 2 (ignore)
WindowCircleOp("spell", -- miniwindow name
1, -- action (ellipse)
64/4, 64/4+(n-1)*64, 64*3/4, 64*3/4+(n-1)*64, -- left, top, right, bottom
rgb, 0, 3, -- pen colour, pen style (solid), pen width
rgb, 0, -- brush colour, brush style (solid)
0, 0, 0, 0) -- extra 1 through 4 (ignore)
WindowLine("spell", -- miniwindow name
64/2, -- x position start point
64/2+(n-1)*64, -- y position start point
math.cos(pct*2*math.pi-math.pi/2)*64/4+64/2, -- x position end point
math.sin(pct*2*math.pi-math.pi/2)*64/4+64/2+(n-1)*64, -- y position end point
ColourNameToRGB("black"), 0, 3) -- pen colour, pen style (solid), pen width
else
WindowRectOp("spell", -- miniwindow name
2, -- action (fill rectangle with colour 1)
0, (n-1)*64, 1*64, n*64, -- left, top, right, bottom
ColourNameToRGB("black"), -- colour 1
0) -- colour 2 (ignore)
end
Redraw()
end
end
continue... |