Skip to content

Instantly share code, notes, and snippets.

@ckaotik
Created November 9, 2014 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckaotik/a04d6570296af018c49a to your computer and use it in GitHub Desktop.
Save ckaotik/a04d6570296af018c49a to your computer and use it in GitHub Desktop.
Cecile_MeterOverlay
local addonName, Engine = ...
----------------------------------------------------------------------------------------------------
-- Numeration module
--
if not IsAddOnLoaded("Numeration") then return; end
local mod = Engine.AddOn:NewModule("Numeration")
local debug = Engine.AddOn:GetModule("debug")
-- toggle window
function mod.Toggle()
Numeration:ToggleVisibility()
end
local emptyTable = {}
local function GetValues(set, unitName, statType)
local mergePets = NumerationCharOptions.petsmerged
local data = set.unit[unitName]
if not data then return 0, 0 end
local total = data[statType] and data[statType].total or 0
local duration = data[statType] and data[statType].time or 0
for petName in pairs(mergePets and data.pets or emptyTable) do
local petData = set.unit[petName][statType]
if petData then
total = total + petData.total
duration = math.max(duration, petData.time or 0)
end
end
local perSecond = duration > 0 and math.floor(total/duration + 0.5) or total
return total, perSecond
end
-- get the sum table
function mod.GetSumtable(scope, mode)
local sumTable = {}
local totalsum, totalpersec = 0, 0
local index = scope == Engine.CURRENT_DATA and 1 or 0
local statType = (mode == Engine.TYPE_HEAL and 'hd') or (mode == Engine.TYPE_DPS and 'dd') or 'dd'
local set = _G.NumerationCharDB[index]
for name, data in pairs(set and set.unit or emptyTable) do
if data.class ~= 'PET' then
local unitData = {
name = data.name,
enclass = data.class,
}
local value, perSecond = GetValues(set, data.name, statType)
if mode == Engine.TYPE_DPS then
unitData.damage = value
unitData.dps = perSecond
elseif mode == Engine.TYPE_HEAL then
unitData.healing = value
unitData.hps = perSecond
end
totalsum = totalsum + value
totalpersec = totalpersec + perSecond
table.insert(sumTable, unitData)
end
end
return sumTable, totalsum, totalpersec
end
function mod.GetSegmentName()
return NumerationCharDB[1] and NumerationCharDB[1].name or ''
end
-- initialize module
function mod:OnInitialize()
mod.meter = Engine.AddOn:GetModule("meter")
mod.meter:RegisterMeter("Numeration",mod.GetSumtable,mod.GetSegmentName,mod.Toggle)
end
@ckaotik
Copy link
Author

ckaotik commented Nov 9, 2014

Don't forget to also follow these two steps:

  • add a <Script file="numeration.lua"/> line to Cecile_MeterOverlay/modules/load_modules.xml
  • add Numeration to the ## OptionalDeps: property in Cecile_MeterOverlay/Cecile_MeterOverlay.toc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment