View Single Post
05-13-17, 05:18 PM   #9
jeruku
A Cobalt Mageweaver
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 223
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:
  1. local SkillFlow = CreateFrame("Frame");
  2. SkillFlow:RegisterEvent("PLAYER_REGEN_ENABLED");
  3. SkillFlow:RegisterEvent("PLAYER_REGEN_DISABLED");
  4. SkillFlow:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
  5.  
  6. SkillFlow.regenEnabled = true;
  7. SkillFlow.queue = {};
  8. SkillFlow.queueSize = 10;
  9.  
  10. local placeholderfunc
  11. local placeholdername
  12.  
  13. local function DoThis(self, spellName)
  14.     if #self.queue < self.queueSize then
  15.         table.insert(self.queue, spellName);
  16.     else
  17.         for i = 1, #self.queue - 1 do
  18.             self.queue[i] = self.queue[i + 1];
  19.         end
  20.  
  21.         self.queue[self.queueSize] = spellName;
  22.     end
  23.  
  24.     -- DUBUGGING ----------------------------------------
  25.     print("\n======== Skill Flow ========");
  26.     for i = 1, #self.queue do
  27.         print(string.format("%d: %s", i, self.queue[i]));
  28.     end
  29.     print("============================");
  30.     -----------------------------------------------------
  31. end
  32.  
  33. local function StopThis()
  34.     placeholderfunc = nil
  35.     placeholdername = nil
  36. end
  37.  
  38. function SkillFlow:PLAYER_REGEN_ENABLED()
  39.     self.regenEnabled = true;
  40.     -- safety measure
  41.     StopThis()
  42. end
  43.  
  44. function SkillFlow:PLAYER_REGEN_DISABLED()
  45.     self.regenEnabled = false;
  46.     if placeholderfunc then
  47.         placeholderfunc(self, placeholdername)
  48.     end
  49.     StopThis()
  50. end
  51.  
  52. function SkillFlow:OnEvent(event, ...)
  53.     self[event](self, event, ...);
  54. end
  55.  
  56. function SkillFlow:COMBAT_LOG_EVENT_UNFILTERED(event, _, subEvent, _, sourceGUID, _, _, _, _, _, _, _, _, spellName, ...)
  57.     if sourceGUID == UnitGUID("player") then
  58.         if subEvent == "SPELL_CAST_SUCCESS" and not self.regenEnabled then
  59.             DoThis(self, spellName)
  60.         elseif self.regenEnabled and not placeholderfunc then
  61.             placeholderfunc = DoThis
  62.             placeholdername = SpellName
  63.             C_Timer.After(1.5, StopThis) -- wait until after global cooldown I suppose.
  64.         end
  65.     end
  66. end
  67.  
  68. SkillFlow:SetScript("OnEvent", SkillFlow.OnEvent);
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison

Last edited by jeruku : 05-13-17 at 05:19 PM. Reason: was incomplete
  Reply With Quote