- Rework on Activity Time, now it will be more accurate with warcraftlogs.com
- Added two new customs: Damage Activity Time and Healing Activity Time. - TimeAttack plugin now have only have six time amount options. - TimeAttack plugin can now share damage results with other players with the same class in the realm. - New API: instance:EnableInstance() active and open a closed instance. - New API: _detalhes:RegisterBackgroundTask (name, func, priority, ...) background task runs slowly when player isn't in group nor inside instances. - New API: _detalhes:UnregisterBackgroundTask (name) cancel a backgroup task. - New API: plugin:RegisterPluginComm (prefix, func) register for receive comm msg. - New API: plugin:UnregisterPluginComm (prefix) unregister a previous registred comm. - New API: plugin:SendPluginCommMessage (prefix, channel, ...) send a msg through channel. - New API: _detalhes:IsConnected() return true is Details! is connected to realm comm channel. - New API: plugin:IsPluginEnabled() return is the plugin is enabled.
This commit is contained in:
+62
-1
@@ -141,4 +141,65 @@ function _detalhes:GetPerformanceRaidType()
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
local background_tasks = {}
|
||||
local task_timers = {
|
||||
["LOW"] = 30,
|
||||
["MEDIUM"] = 18,
|
||||
["HIGH"] = 10,
|
||||
}
|
||||
|
||||
function _detalhes:RegisterBackgroundTask (name, func, priority, ...)
|
||||
|
||||
assert (type (self) == "table", "RegisterBackgroundTask 'self' must be a table.")
|
||||
assert (type (name) == "string", "RegisterBackgroundTask param #1 must be a string.")
|
||||
if (type (func) == "string") then
|
||||
assert (type (self [func]) == "function", "RegisterBackgroundTask param #2 function not found on main object.")
|
||||
else
|
||||
assert (type (func) == "function", "RegisterBackgroundTask param #2 expect a function or function name.")
|
||||
end
|
||||
|
||||
priority = priority or "LOW"
|
||||
priority = string.upper (priority)
|
||||
if (not task_timers [priority]) then
|
||||
priority = "LOW"
|
||||
end
|
||||
|
||||
if (background_tasks [name]) then
|
||||
background_tasks [name].func = func
|
||||
background_tasks [name].priority = priority
|
||||
background_tasks [name].args = {...}
|
||||
background_tasks [name].args_amt = select ("#", ...)
|
||||
background_tasks [name].object = self
|
||||
return
|
||||
else
|
||||
background_tasks [name] = {func = func, lastexec = time(), priority = priority, nextexec = time() + task_timers [priority] * 60, args = {...}, args_amt = select ("#", ...), object = self}
|
||||
end
|
||||
end
|
||||
|
||||
function _detalhes:UnregisterBackgroundTask (name)
|
||||
background_tasks [name] = nil
|
||||
end
|
||||
|
||||
function _detalhes:DoBackgroundTasks()
|
||||
if (_detalhes:GetZoneType() ~= "none" or _detalhes:InGroup()) then
|
||||
return
|
||||
end
|
||||
|
||||
local t = time()
|
||||
|
||||
for taskName, taskTable in pairs (background_tasks) do
|
||||
if (t > taskTable.nextexec) then
|
||||
if (type (taskTable.func) == "string") then
|
||||
taskTable.object [taskTable.func] (taskTable.object, unpack (taskTable.args, 1, taskTable.args_amt))
|
||||
else
|
||||
taskTable.func (unpack (taskTable.args, 1, taskTable.args_amt))
|
||||
end
|
||||
|
||||
taskTable.nextexec = random (30, 120) + t + (task_timers [taskTable.priority] * 60)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
_detalhes.background_tasks_loop = _detalhes:ScheduleRepeatingTimer ("DoBackgroundTasks", 120)
|
||||
|
||||
Reference in New Issue
Block a user