Originally Posted by dominoid
If not, what is the best way to throttle OnUpdate so its not too intensive?
|
Just use a buffer like that:
Lua Code:
local BufferTable = {}
local function BufferReached(key, buffer)
if key == nil then return end
if BufferTable[key] == nil then BufferTable[key] = {} end
BufferTable[key].buffer = buffer or 3
BufferTable[key].now = GetFrameTimeSeconds()
if BufferTable[key].last == nil then BufferTable[key].last = BufferTable[key].now end
BufferTable[key].diff = BufferTable[key].now - BufferTable[key].last
BufferTable[key].eval = BufferTable[key].diff >= BufferTable[key].buffer
if BufferTable[key].eval then BufferTable[key].last = BufferTable[key].now end
return BufferTable[key].eval
end
function GroupDamage.onUpdateHandler()
if not BufferReached("general", 1) then return; end
GroupDamage:updateCombatData()
GroupDamage:orderCurrentRanking()
GroupDamage:fillMainTarget()
GroupDamage:updateMissingGroupMembers()
GroupDamage:clearOldFights()
GroupDamage:updatePanel()
end
And then use
Lua Code:
self.control:SetHandler("OnUpdate", function() self.onUpdateHandler() end)
to set the handler, setting it in xml at least doesn't work for me. The second argument on BufferReached() sets the interval.