Here is a sample of how it might be done, I threw it together real quick so it is without guarantee.
It will wait 1.5 seconds, global cooldown, after a spell cast waiting to see if you had entered combat.
Lua Code:
local SkillFlow = CreateFrame("Frame");
SkillFlow:RegisterEvent("PLAYER_REGEN_ENABLED");
SkillFlow:RegisterEvent("PLAYER_REGEN_DISABLED");
SkillFlow:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
SkillFlow.regenEnabled = true;
SkillFlow.queue = {};
SkillFlow.queueSize = 10;
local placeholderfunc
local placeholdername
local function DoThis(self, spellName)
if #self.queue < self.queueSize then
table.insert(self.queue, spellName);
else
for i = 1, #self.queue - 1 do
self.queue[i] = self.queue[i + 1];
end
self.queue[self.queueSize] = spellName;
end
-- DUBUGGING ----------------------------------------
print("\n======== Skill Flow ========");
for i = 1, #self.queue do
print(string.format("%d: %s", i, self.queue[i]));
end
print("============================");
-----------------------------------------------------
end
local function StopThis()
placeholderfunc = nil
placeholdername = nil
end
function SkillFlow:PLAYER_REGEN_ENABLED()
self.regenEnabled = true;
-- safety measure
StopThis()
end
function SkillFlow:PLAYER_REGEN_DISABLED()
self.regenEnabled = false;
if placeholderfunc then
placeholderfunc(self, placeholdername)
end
StopThis()
end
function SkillFlow:OnEvent(event, ...)
self[event](self, event, ...);
end
function SkillFlow:COMBAT_LOG_EVENT_UNFILTERED(event, _, subEvent, _, sourceGUID, _, _, _, _, _, _, _, _, spellName, ...)
if sourceGUID == UnitGUID("player") then
if subEvent == "SPELL_CAST_SUCCESS" and not self.regenEnabled then
DoThis(self, spellName)
elseif self.regenEnabled and not placeholderfunc then
placeholderfunc = DoThis
placeholdername = SpellName
C_Timer.After(1.5, StopThis) -- wait until after global cooldown I suppose.
end
end
end
SkillFlow:SetScript("OnEvent", SkillFlow.OnEvent);