Thread Tools Display Modes
01-23-17, 11:32 AM   #21
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,903
If the addon is disabled then there will be no entry in the addon list with your Enable/Disable buttona because the addon hasn't loaded because it is diabled. It would have to be enabled bia the Addons button on the game menu or at the character selection screen.

To Test (still has the message code to show that it won't get printed):
Lua Code:
  1. local TaintOfTheSea     = GetSpellInfo(228054)
  2. local Ticker            = 0
  3. local MoveMessage       = "{moon} MOVE TO MOON {moon}"
  4. local DispelMessage     = "Dispell on {moon} in "
  5. local debuffexists      = false
  6. local titleFont = [=[Interface\Addons\HelyaAssist\fonts\accid___.ttf]=]
  7. local folder = "HelyaAssist"
  8. local ds = 0
  9.  
  10. -- Adds HelyaAssist to interface in addons
  11. local myAddon = {};
  12. myAddon.panel = CreateFrame( "Frame", "myAddonPanel", UIParent);
  13. myAddon.panel.name = "HelyaAssist";
  14. InterfaceOptions_AddCategory(myAddon.panel);
  15.  
  16. --Create the button (enable)
  17. local mybutton1 = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  18. mybutton1:SetPoint("CENTER", -255,220)
  19. mybutton1:SetWidth(80)
  20. mybutton1:SetHeight(22)
  21. mybutton1:SetText("Enabled")
  22.  
  23. --Create the button (disable)
  24. local mybutton2 = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  25. mybutton2:SetPoint("CENTER", -160,220)
  26. mybutton2:SetWidth(80)
  27. mybutton2:SetHeight(22)
  28. mybutton2:SetText("Disabled")
  29.  
  30. --Text in panel
  31. local MOD_TextFrame = CreateFrame("Frame", nil, myAddonPanel);
  32. MOD_TextFrame:ClearAllPoints();
  33. MOD_TextFrame:SetHeight(300);
  34. MOD_TextFrame:SetWidth(300);
  35. MOD_TextFrame:SetScript("OnUpdate", MOD_TextFrame_OnUpdate);
  36. MOD_TextFrame.text = MOD_TextFrame:CreateFontString(nil, "BACKGROUND", "PVPInfoTextFont");
  37. MOD_TextFrame.text:SetAllPoints();
  38. MOD_TextFrame:SetPoint("CENTER", -245, 260);
  39. MOD_TextFrameTime = 0;
  40. MOD_TextFrame.text:SetText('|cffffff00HelyaAssist');
  41. MOD_TextFrame.text:SetFont(titleFont, 19);
  42.  
  43.  --If mybutton2 is clicked, then disable HelyaAssist (disable button)
  44. mybutton2:SetScript("OnClick", function(self, button, down)
  45.     local playerName = UnitName("player")
  46.     DisableAddOn(folder, playerName)
  47.     HelyaAssistAddon = true
  48.     ReloadUI()
  49. end)
  50.  
  51. -- PLAYER_ENTERING_WORLD for Disable button
  52. local function eventHandlerE(self, event, ...)
  53. print(event, folder, HelyaAssistAddon)
  54.     local playerName = UnitName("player")
  55.     if HelyaAssistAddon and GetAddOnEnableState(playerName, folder) == 0 then
  56.         HelyaAssistAddon = nil
  57.         print('|cffffff00HelyaAssist is now Disabled')
  58.     end
  59. --    self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  60. end
  61.  
  62. local frame = CreateFrame("FRAME", "FooAddonFrame");
  63. frame:SetScript("OnEvent", eventHandlerE);
  64. frame:RegisterEvent("PLAYER_ENTERING_WORLD");
  65.  
  66.  
  67. --If MyButton1 is clicked , then Enable HelyaAssist (enable button)
  68. mybutton1:SetScript("OnClick", function(self, button, down)
  69. local playerName2 = UnitName("player")
  70. EnableAddOn(folder, playerName2)
  71. ReloadUI()
  72. end)
  73.  
  74.  
  75.  
  76.  
  77. -- PLAYER_ENTERING_WORLD for Enable button
  78.  
  79.  
  80.  
  81.  
  82. local function UpdateTicker()
  83.     if Ticker < 1 or not debuffexists then return end
  84.  
  85.     SendChatMessage((Ticker > 5) and MoveMessage or DispelMessage .. Ticker, "Yell", nil, name)
  86.     Ticker = Ticker - 1
  87.  
  88.     C_Timer.After((Ticker > 5) and 1.5 or 0.4, UpdateTicker)
  89. end
  90.  
  91. local function UNIT_AURA()
  92.     local name, _, _, _, _, duration, expires = UnitDebuff("player", TaintOfTheSea)
  93.    
  94.     if name then
  95.         if not debuffexists then
  96.             debuffexists = true --player just got the debuff
  97.             Ticker = 6
  98.             UpdateTicker()
  99.         end
  100.     else
  101.         debuffexists = false -- doesn't exist
  102.     end
  103. end
  104.  
  105. local eventframe = CreateFrame("Frame")
  106. eventframe:RegisterUnitEvent("UNIT_AURA", "player")
  107. eventframe:SetScript("OnEvent", UNIT_AURA)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-23-17, 11:34 AM   #22
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Originally Posted by pas06 View Post
i don't get the logic behind this. You wan't to enable an addon from an disabled addon?
Maybe i am bad on explaining ,
Well bassicly the code fizzlemizz helped out with makes it so if i click on the disable button it will disable the addon and print out "HelyaAssist is now disabled"

I just want to add the same principle for the enable button aswell, so if i click on enable button it will enable the addon if it already was disabled and print out "HelyaAssist is now enabled"
Hope this make sense <3

best regards!
  Reply With Quote
01-23-17, 11:34 AM   #23
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,903
Originally Posted by pas06 View Post
i don't get the logic behind this. You wan't to enable an addon from an disabled addon?
That addon won't be able to enable itself but the game "AddOns" buttons will.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-23-17, 11:36 AM   #24
pas06
A Theradrim Guardian
Join Date: Apr 2009
Posts: 62
Originally Posted by Fizzlemizz View Post
That addon won't be able to enable itself but the game "AddOns" buttons will.
but thats exactly what it sounds like he wants to do: enable itself
  Reply With Quote
01-23-17, 11:37 AM   #25
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Originally Posted by Fizzlemizz View Post
If the addon is disabled then there will be no entry in the addon list with your Enable/Disable buttona because the addon hasn't loaded because it is diabled. It would have to be enabled bia the Addons button on the game menu or at the character selection screen.

To Test (still has the message code to show that it won't get printed):
Lua Code:
  1. local TaintOfTheSea     = GetSpellInfo(228054)
  2. local Ticker            = 0
  3. local MoveMessage       = "{moon} MOVE TO MOON {moon}"
  4. local DispelMessage     = "Dispell on {moon} in "
  5. local debuffexists      = false
  6. local titleFont = [=[Interface\Addons\HelyaAssist\fonts\accid___.ttf]=]
  7. local folder = "HelyaAssist"
  8. local ds = 0
  9.  
  10. -- Adds HelyaAssist to interface in addons
  11. local myAddon = {};
  12. myAddon.panel = CreateFrame( "Frame", "myAddonPanel", UIParent);
  13. myAddon.panel.name = "HelyaAssist";
  14. InterfaceOptions_AddCategory(myAddon.panel);
  15.  
  16. --Create the button (enable)
  17. local mybutton1 = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  18. mybutton1:SetPoint("CENTER", -255,220)
  19. mybutton1:SetWidth(80)
  20. mybutton1:SetHeight(22)
  21. mybutton1:SetText("Enabled")
  22.  
  23. --Create the button (disable)
  24. local mybutton2 = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  25. mybutton2:SetPoint("CENTER", -160,220)
  26. mybutton2:SetWidth(80)
  27. mybutton2:SetHeight(22)
  28. mybutton2:SetText("Disabled")
  29.  
  30. --Text in panel
  31. local MOD_TextFrame = CreateFrame("Frame", nil, myAddonPanel);
  32. MOD_TextFrame:ClearAllPoints();
  33. MOD_TextFrame:SetHeight(300);
  34. MOD_TextFrame:SetWidth(300);
  35. MOD_TextFrame:SetScript("OnUpdate", MOD_TextFrame_OnUpdate);
  36. MOD_TextFrame.text = MOD_TextFrame:CreateFontString(nil, "BACKGROUND", "PVPInfoTextFont");
  37. MOD_TextFrame.text:SetAllPoints();
  38. MOD_TextFrame:SetPoint("CENTER", -245, 260);
  39. MOD_TextFrameTime = 0;
  40. MOD_TextFrame.text:SetText('|cffffff00HelyaAssist');
  41. MOD_TextFrame.text:SetFont(titleFont, 19);
  42.  
  43.  --If mybutton2 is clicked, then disable HelyaAssist (disable button)
  44. mybutton2:SetScript("OnClick", function(self, button, down)
  45.     local playerName = UnitName("player")
  46.     DisableAddOn(folder, playerName)
  47.     HelyaAssistAddon = true
  48.     ReloadUI()
  49. end)
  50.  
  51. -- PLAYER_ENTERING_WORLD for Disable button
  52. local function eventHandlerE(self, event, ...)
  53. print(event, folder, HelyaAssistAddon)
  54.     local playerName = UnitName("player")
  55.     if HelyaAssistAddon and GetAddOnEnableState(playerName, folder) == 0 then
  56.         HelyaAssistAddon = nil
  57.         print('|cffffff00HelyaAssist is now Disabled')
  58.     end
  59. --    self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  60. end
  61.  
  62. local frame = CreateFrame("FRAME", "FooAddonFrame");
  63. frame:SetScript("OnEvent", eventHandlerE);
  64. frame:RegisterEvent("PLAYER_ENTERING_WORLD");
  65.  
  66.  
  67. --If MyButton1 is clicked , then Enable HelyaAssist (enable button)
  68. mybutton1:SetScript("OnClick", function(self, button, down)
  69. local playerName2 = UnitName("player")
  70. EnableAddOn(folder, playerName2)
  71. ReloadUI()
  72. end)
  73.  
  74.  
  75.  
  76.  
  77. -- PLAYER_ENTERING_WORLD for Enable button
  78.  
  79.  
  80.  
  81.  
  82. local function UpdateTicker()
  83.     if Ticker < 1 or not debuffexists then return end
  84.  
  85.     SendChatMessage((Ticker > 5) and MoveMessage or DispelMessage .. Ticker, "Yell", nil, name)
  86.     Ticker = Ticker - 1
  87.  
  88.     C_Timer.After((Ticker > 5) and 1.5 or 0.4, UpdateTicker)
  89. end
  90.  
  91. local function UNIT_AURA()
  92.     local name, _, _, _, _, duration, expires = UnitDebuff("player", TaintOfTheSea)
  93.    
  94.     if name then
  95.         if not debuffexists then
  96.             debuffexists = true --player just got the debuff
  97.             Ticker = 6
  98.             UpdateTicker()
  99.         end
  100.     else
  101.         debuffexists = false -- doesn't exist
  102.     end
  103. end
  104.  
  105. local eventframe = CreateFrame("Frame")
  106. eventframe:RegisterUnitEvent("UNIT_AURA", "player")
  107. eventframe:SetScript("OnEvent", UNIT_AURA)
Ah alright make sense , completely understandable! is there anyway else around it then? because on all other addons there is like options if you want to have the addon enabled or disabled , I have tried looking through like dbm's lua code and stuff like that.
Best regards!
  Reply With Quote
01-23-17, 11:37 AM   #26
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,903
Originally Posted by pas06 View Post
but thats exactly what it sounds like he wants to do: enable itself
It is and it's not possible. Neither will the message print after the ReloadUI bacause the addon is now disabled. Trying to caal the function with the message atraight after the ReloadUI won't work either because at this stage you screen has gone blank and the addon, along with all the others are being unloaded.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-23-17, 11:38 AM   #27
pas06
A Theradrim Guardian
Join Date: Apr 2009
Posts: 62
i know, i guess he doesn't understand it (yet)
  Reply With Quote
01-23-17, 11:57 AM   #28
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Originally Posted by Fizzlemizz View Post
It is and it's not possible. Neither will the message print after the ReloadUI bacause the addon is now disabled. Trying to caal the function with the message atraight after the ReloadUI won't work either because at this stage you screen has gone blank and the addon, along with all the others are being unloaded.
Okay ye , pas06 i understand that if the addon is disabled and is not reponding together with the game and calling for something that is disabled wont work. Pretty much saying like if a addon is not disabled, why does it not work?

My question now was is there another way in the code to make the addon ignore all this code, if buttonDisabled is clicked
Lua Code:
  1. local function UpdateTicker()
  2.     if Ticker < 1 or not debuffexists then return end
  3.  
  4.     SendChatMessage((Ticker > 5) and MoveMessage or DispelMessage .. Ticker, "Yell", nil, name)
  5.     Ticker = Ticker - 1
  6.  
  7.     C_Timer.After((Ticker > 5) and 1.5 or 0.4, UpdateTicker)
  8. end
  9.  
  10. local function UNIT_AURA()
  11.     local name, _, _, _, _, duration, expires = UnitDebuff("player", TaintOfTheSea)
  12.    
  13.     if name then
  14.         if not debuffexists then
  15.             debuffexists = true --player just got the debuff
  16.             Ticker = 6
  17.             UpdateTicker()
  18.         end
  19.     else
  20.         debuffexists = false -- doesn't exist
  21.     end
  22. end
  23.  
  24. local eventframe = CreateFrame("Frame")
  25. eventframe:RegisterUnitEvent("UNIT_AURA", "player")
  26. eventframe:SetScript("OnEvent", UNIT_AURA)
If there is another way around instead of disable the addon through the panel which will make the addon completely disabled so you have to enable it manually because you can't call code from a program that is not running.
  Reply With Quote
01-23-17, 11:58 AM   #29
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,903
If you don't want to try pas06s approach (which I haven't looked at but may well be better) then something like (dry coded so may not be exactly correct)
Edit:You will have to delete your HelyaAssistAddon.lua file from the SavedVariables folder while logged out or you will get errors.
Edit2: if you're not seeing the message, change
if not not HelyaAssistAddon.shown then
too
if not HelyaAssistAddon.shown then

Lua Code:
  1. local TaintOfTheSea     = GetSpellInfo(228054)
  2. local Ticker            = 0
  3. local MoveMessage       = "{moon} MOVE TO MOON {moon}"
  4. local DispelMessage     = "Dispell on {moon} in "
  5. local debuffexists      = false
  6. local titleFont = [=[Interface\Addons\HelyaAssist\fonts\accid___.ttf]=]
  7. local folder = "HelyaAssist"
  8. local ds = 0
  9.  
  10. -- Adds HelyaAssist to interface in addons
  11. local myAddon = {};
  12. myAddon.panel = CreateFrame( "Frame", "myAddonPanel", UIParent);
  13. myAddon.panel.name = "HelyaAssist";
  14. InterfaceOptions_AddCategory(myAddon.panel);
  15.  
  16. --Create the button (enable)
  17. local mybutton1 = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  18. mybutton1:SetPoint("CENTER", -255,220)
  19. mybutton1:SetWidth(80)
  20. mybutton1:SetHeight(22)
  21. mybutton1:SetText("Enabled")
  22.  
  23. --Create the button (disable)
  24. local mybutton2 = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  25. mybutton2:SetPoint("CENTER", -160,220)
  26. mybutton2:SetWidth(80)
  27. mybutton2:SetHeight(22)
  28. mybutton2:SetText("Disabled")
  29.  
  30. --Text in panel
  31. local MOD_TextFrame = CreateFrame("Frame", nil, myAddonPanel);
  32. MOD_TextFrame:ClearAllPoints();
  33. MOD_TextFrame:SetHeight(300);
  34. MOD_TextFrame:SetWidth(300);
  35. MOD_TextFrame:SetScript("OnUpdate", MOD_TextFrame_OnUpdate);
  36. MOD_TextFrame.text = MOD_TextFrame:CreateFontString(nil, "BACKGROUND", "PVPInfoTextFont");
  37. MOD_TextFrame.text:SetAllPoints();
  38. MOD_TextFrame:SetPoint("CENTER", -245, 260);
  39. MOD_TextFrameTime = 0;
  40. MOD_TextFrame.text:SetText('|cffffff00HelyaAssist');
  41. MOD_TextFrame.text:SetFont(titleFont, 19);
  42.  
  43.  --If mybutton2 is clicked, then disable HelyaAssist (disable button)
  44. mybutton2:SetScript("OnClick", function(self, button, down)
  45.     local playerName = UnitName("player")
  46. --    DisableAddOn(folder, playerName)
  47.     HelyaAssistAddon.disabled = true
  48.     HelyaAssistAddon.shown = nil
  49.     ReloadUI()
  50. end)
  51.  
  52. -- PLAYER_ENTERING_WORLD for Disable button
  53. local function eventHandlerE(self, event, ...)
  54.     if not HelyaAssistAddon then
  55.  
  56.         HelyaAssistAddon = {}
  57.     end
  58.     local playerName = UnitName("player")
  59.     if HelyaAssistAddon.disabled then
  60.             if not HelyaAssistAddon.shown then
  61.                 HelyaAssistAddon.shown = true
  62.                 print('|cffffff00HelyaAssist is now Disabled')
  63.             end
  64.         mybutton1:Enable()
  65.         mybutton2:Disable()
  66.     else
  67.         mybutton2:Enable()
  68.         mybutton1:Disable()
  69.     end
  70.     self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  71. end
  72.  
  73. local frame = CreateFrame("FRAME", "FooAddonFrame");
  74. frame:SetScript("OnEvent", eventHandlerE);
  75. frame:RegisterEvent("PLAYER_ENTERING_WORLD");
  76.  
  77.  
  78. --If MyButton1 is clicked , then Enable HelyaAssist (enable button)
  79. mybutton1:SetScript("OnClick", function(self, button, down)
  80. local playerName2 = UnitName("player")
  81. --EnableAddOn(folder, playerName2)
  82.     HelyaAssistAddon.disabled = nil
  83.     HelyaAssistAddon.shown = nil
  84.  
  85. ReloadUI()
  86. end)
  87.  
  88.  
  89.  
  90. -- PLAYER_ENTERING_WORLD for Enable button
  91.  
  92.  
  93.  
  94.  
  95. local function UpdateTicker()
  96.     if Ticker < 1 or not debuffexists then return end
  97.  
  98.     SendChatMessage((Ticker > 5) and MoveMessage or DispelMessage .. Ticker, "Yell", nil, name)
  99.     Ticker = Ticker - 1
  100.  
  101.     C_Timer.After((Ticker > 5) and 1.5 or 0.4, UpdateTicker)
  102. end
  103.  
  104. local function UNIT_AURA()
  105.     local name, _, _, _, _, duration, expires = UnitDebuff("player", TaintOfTheSea)
  106.    
  107.     if name then
  108.         if not debuffexists then
  109.             debuffexists = true --player just got the debuff
  110.             Ticker = 6
  111.             UpdateTicker()
  112.         end
  113.     else
  114.         debuffexists = false -- doesn't exist
  115.     end
  116. end
  117.  
  118. local eventframe = CreateFrame("Frame")
  119. if HelyaAssistAddon and HelyaAssistAddon.disabled then
  120.     MOD_TextFrame:Hide()
  121. else
  122.     eventframe:RegisterUnitEvent("UNIT_AURA", "player")
  123.     eventframe:SetScript("OnEvent", UNIT_AURA)
  124. end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 01-23-17 at 12:18 PM.
  Reply With Quote
01-23-17, 12:05 PM   #30
pas06
A Theradrim Guardian
Join Date: Apr 2009
Posts: 62
Fizzlemizz, feel free to look at my code in post 13, i don't have the biggest experience, but i feel like i did a good job with that code(after editing that post 5 times ).
  Reply With Quote
01-23-17, 12:09 PM   #31
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Originally Posted by Fizzlemizz View Post
If you don't want to try pas06s approach (which I haven't looked at but mauy well be better) then something like (dry coded so may not be exactly correct)
Lua Code:
  1. local TaintOfTheSea     = GetSpellInfo(228054)
  2. local Ticker            = 0
  3. local MoveMessage       = "{moon} MOVE TO MOON {moon}"
  4. local DispelMessage     = "Dispell on {moon} in "
  5. local debuffexists      = false
  6. local titleFont = [=[Interface\Addons\HelyaAssist\fonts\accid___.ttf]=]
  7. local folder = "HelyaAssist"
  8. local ds = 0
  9.  
  10. -- Adds HelyaAssist to interface in addons
  11. local myAddon = {};
  12. myAddon.panel = CreateFrame( "Frame", "myAddonPanel", UIParent);
  13. myAddon.panel.name = "HelyaAssist";
  14. InterfaceOptions_AddCategory(myAddon.panel);
  15.  
  16. --Create the button (enable)
  17. local mybutton1 = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  18. mybutton1:SetPoint("CENTER", -255,220)
  19. mybutton1:SetWidth(80)
  20. mybutton1:SetHeight(22)
  21. mybutton1:SetText("Enabled")
  22.  
  23. --Create the button (disable)
  24. local mybutton2 = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  25. mybutton2:SetPoint("CENTER", -160,220)
  26. mybutton2:SetWidth(80)
  27. mybutton2:SetHeight(22)
  28. mybutton2:SetText("Disabled")
  29.  
  30. --Text in panel
  31. local MOD_TextFrame = CreateFrame("Frame", nil, myAddonPanel);
  32. MOD_TextFrame:ClearAllPoints();
  33. MOD_TextFrame:SetHeight(300);
  34. MOD_TextFrame:SetWidth(300);
  35. MOD_TextFrame:SetScript("OnUpdate", MOD_TextFrame_OnUpdate);
  36. MOD_TextFrame.text = MOD_TextFrame:CreateFontString(nil, "BACKGROUND", "PVPInfoTextFont");
  37. MOD_TextFrame.text:SetAllPoints();
  38. MOD_TextFrame:SetPoint("CENTER", -245, 260);
  39. MOD_TextFrameTime = 0;
  40. MOD_TextFrame.text:SetText('|cffffff00HelyaAssist');
  41. MOD_TextFrame.text:SetFont(titleFont, 19);
  42.  
  43.  --If mybutton2 is clicked, then disable HelyaAssist (disable button)
  44. mybutton2:SetScript("OnClick", function(self, button, down)
  45.     local playerName = UnitName("player")
  46. --    DisableAddOn(folder, playerName)
  47.     HelyaAssistAddon.disabled = true
  48.     HelyaAssistAddon.shown = nil
  49.     ReloadUI()
  50. end)
  51.  
  52. -- PLAYER_ENTERING_WORLD for Disable button
  53. local function eventHandlerE(self, event, ...)
  54.     if not HelyaAssistAddon then
  55.         HelyaAssistAddon = {}
  56.     end
  57.     local playerName = UnitName("player")
  58.     if HelyaAssistAddon and HelyaAssistAddon then
  59.             if not not HelyaAssistAddon then
  60.                 HelyaAssistAddon = true
  61.                 print('|cffffff00HelyaAssist is now Disabled')
  62.             end
  63.         mybutton1:Enable()
  64.         mybutton2:Disable()
  65.     else
  66.         mybutton2:Enable()
  67.         mybutton1:Disable()
  68.     end
  69.     self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  70. end
  71.  
  72. local frame = CreateFrame("FRAME", "FooAddonFrame");
  73. frame:SetScript("OnEvent", eventHandlerE);
  74. frame:RegisterEvent("PLAYER_ENTERING_WORLD");
  75.  
  76.  
  77. --If MyButton1 is clicked , then Enable HelyaAssist (enable button)
  78. mybutton1:SetScript("OnClick", function(self, button, down)
  79. local playerName2 = UnitName("player")
  80. --EnableAddOn(folder, playerName2)
  81.     HelyaAssistAddon.disabled = nil
  82.     HelyaAssistAddon.shown = nil
  83.  
  84. ReloadUI()
  85. end)
  86.  
  87.  
  88.  
  89. -- PLAYER_ENTERING_WORLD for Enable button
  90.  
  91.  
  92.  
  93.  
  94. local function UpdateTicker()
  95.     if Ticker < 1 or not debuffexists then return end
  96.  
  97.     SendChatMessage((Ticker > 5) and MoveMessage or DispelMessage .. Ticker, "Yell", nil, name)
  98.     Ticker = Ticker - 1
  99.  
  100.     C_Timer.After((Ticker > 5) and 1.5 or 0.4, UpdateTicker)
  101. end
  102.  
  103. local function UNIT_AURA()
  104.     local name, _, _, _, _, duration, expires = UnitDebuff("player", TaintOfTheSea)
  105.    
  106.     if name then
  107.         if not debuffexists then
  108.             debuffexists = true --player just got the debuff
  109.             Ticker = 6
  110.             UpdateTicker()
  111.         end
  112.     else
  113.         debuffexists = false -- doesn't exist
  114.     end
  115. end
  116.  
  117. local eventframe = CreateFrame("Frame")
  118. if HelyaAssistAddon and HelyaAssistAddon.disabled then
  119.     MOD_TextFrame:Hide()
  120. else
  121.     eventframe:RegisterUnitEvent("UNIT_AURA", "player")
  122.     eventframe:SetScript("OnEvent", UNIT_AURA)
  123. end
Okay ye, Tried it out but don't work.

This error pops if you click enable button for example
Lua Code:
  1. Message: Interface\AddOns\HelyaAssist\HelyaAssist.lua:81: attempt to index global 'HelyaAssistAddon' (a boolean value)
  2. Time: 01/23/17 20:08:21
  3. Count: 1
  4. Stack: [C]: ?
  5. Interface\AddOns\HelyaAssist\HelyaAssist.lua:81: in function <Interface\AddOns\HelyaAssist\HelyaAssist.lua:78>
  Reply With Quote
01-23-17, 12:13 PM   #32
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,903
Just updated the code and see the part about deleting your SavedVariables file.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-23-17, 12:20 PM   #33
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Originally Posted by Fizzlemizz View Post
Just updated the code and see the part about deleting your SavedVariables file.
What do you mean?

if u mean that this should be removed from the .toc file i tried that but that gives more error becuase HelyaAssistAddon is used in the .lua code.
Lua Code:
  1. ## SavedVariables: HelyaAssistAddon
  Reply With Quote
01-23-17, 12:23 PM   #34
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,903
The file HelyaAssistAddon.lua needs to be deleted from your WTF\Account\[userd id']\SavedVariables folder.

This is where the information is saved between sessions and the format has changed in the new version of the addon, make sure you're logged out before deleting otherwise the file will be re-written when you reload or exit the game.

You only need to delete it once so the game can start with a fresh file.

The code disables/enables the addon for all characters. If you want character by character then you will have to save the disabled/shown information for each character-realm or use ## SavedVariablesPerCharacter: instead of ## SavedVariables:.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 01-23-17 at 12:40 PM.
  Reply With Quote
01-23-17, 01:46 PM   #35
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Originally Posted by Fizzlemizz View Post
The file HelyaAssistAddon.lua needs to be deleted from your WTF\Account\[userd id']\SavedVariables folder.

This is where the information is saved between sessions and the format has changed in the new version of the addon, make sure you're logged out before deleting otherwise the file will be re-written when you reload or exit the game.

You only need to delete it once so the game can start with a fresh file.

The code disables/enables the addon for all characters. If you want character by character then you will have to save the disabled/shown information for each character-realm or use ## SavedVariablesPerCharacter: instead of ## SavedVariables:.
Oh okay then it works
Can you just help me tweak pas06's code? all buttons are working fine with the print , just as i wanted but if i click on disable and then go and fight helya and get the debuff , it will still run this code
Lua Code:
  1. local function UpdateTicker()
  2.     if Ticker < 1 or not debuffexists then return end
  3.  
  4.     SendChatMessage((Ticker > 5) and MoveMessage or DispelMessage .. Ticker, "Yell", nil, name)
  5.     Ticker = Ticker - 1
  6.  
  7.     C_Timer.After((Ticker > 5) and 1.5 or 0.7, UpdateTicker)
  8. end
  9.  
  10. local function UNIT_AURA()
  11.     local name, _, _, _, _, duration, expires = UnitDebuff("player", TaintOfTheSea)
  12.    
  13.     if name then
  14.         if not debuffexists then
  15.             debuffexists = true --player just got the debuff
  16.             Ticker = 6
  17.             UpdateTicker()
  18.         end
  19.     else
  20.         debuffexists = false -- doesn't exist
  21.     end
  22. end
  23.  
  24. local eventframe = CreateFrame("Frame")
  25. if HelyaAssistAddon and HelyaAssistAddon.disabled then
  26.     MOD_TextFrame:Hide()
  27. else
  28.     eventframe:RegisterUnitEvent("UNIT_AURA", "player")
  29.     eventframe:SetScript("OnEvent", UNIT_AURA)
  30. end

DO you know how to do so if the disable button is registered it will not run that code if i get the debuff on me?

This is the whole code just so you know which one i am talking about!
Lua Code:
  1. local TaintOfTheSea     = GetSpellInfo(228054)
  2. local Ticker            = 0
  3. local MoveMessage       = "{moon} MOVE TO MOON {moon}"
  4. local DispelMessage     = "Dispell on {moon} in "
  5. local debuffexists      = false
  6. local titleFont = [=[Interface\Addons\HelyaAssist\fonts\accid___.ttf]=]
  7. local folder = "HelyaAssist"
  8. local ds = 0
  9.  
  10. -- Adds HelyaAssist to interface in addons
  11. local myAddon = {};
  12. myAddon.panel = CreateFrame( "Frame", "myAddonPanel", UIParent);
  13. myAddon.panel.name = "HelyaAssist";
  14. InterfaceOptions_AddCategory(myAddon.panel);
  15.  
  16. --Create the button (enable)
  17. local buttonEnable = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  18. buttonEnable:SetPoint("CENTER", -255,220)
  19. buttonEnable:SetWidth(80)
  20. buttonEnable:SetHeight(22)
  21. buttonEnable:SetText("Enabled")
  22.  
  23. --Create the button (disable)
  24. local buttonDisable = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  25. buttonDisable:SetPoint("CENTER", -160,220)
  26. buttonDisable:SetWidth(80)
  27. buttonDisable:SetHeight(22)
  28. buttonDisable:SetText("Disabled")
  29.  
  30. --Text in panel
  31. local MOD_TextFrame = CreateFrame("Frame", nil, myAddonPanel);
  32. MOD_TextFrame:ClearAllPoints();
  33. MOD_TextFrame:SetHeight(300);
  34. MOD_TextFrame:SetWidth(300);
  35. MOD_TextFrame:SetScript("OnUpdate", MOD_TextFrame_OnUpdate);
  36. MOD_TextFrame.text = MOD_TextFrame:CreateFontString(nil, "BACKGROUND", "PVPInfoTextFont");
  37. MOD_TextFrame.text:SetAllPoints();
  38. MOD_TextFrame:SetPoint("CENTER", -245, 260);
  39. MOD_TextFrameTime = 0;
  40. MOD_TextFrame.text:SetText('|cffffff00HelyaAssist');
  41. MOD_TextFrame.text:SetFont(titleFont, 19);
  42.  
  43.  --If mybutton2 is clicked, then disable HelyaAssist (disable button)
  44. buttonDisable:SetScript("OnClick", function(self, button, down)
  45.     local playerName = UnitName("player")
  46. --    DisableAddOn(folder, playerName)
  47.     HelyaAssistAddon.disabled = true
  48.     HelyaAssistAddon.shown = nil
  49.     ReloadUI()
  50. end)
  51.  
  52. -- PLAYER_ENTERING_WORLD for Disable button
  53. local function eventHandlerE(self, event, ...)
  54.     if not HelyaAssistAddon then
  55.         HelyaAssistAddon = {}
  56.     end
  57.     local playerName = UnitName("player")
  58.     if HelyaAssistAddon.disabled then
  59.             if not HelyaAssistAddon.shown then
  60.                 HelyaAssistAddon.shown = true
  61.                 print('|cffffff00HelyaAssist is now Disabled')
  62.             end
  63.         buttonEnable:Enable()
  64.         buttonDisable:Disable()
  65.     else
  66.         print('|cffffff00HelyaAssist is now Enable')
  67.         buttonDisable:Enable()
  68.         buttonEnable:Disable()
  69.     end
  70.     self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  71. end
  72.  
  73. local frame = CreateFrame("FRAME", "FooAddonFrame");
  74. frame:SetScript("OnEvent", eventHandlerE);
  75. frame:RegisterEvent("PLAYER_ENTERING_WORLD");
  76.  
  77.  
  78. --If buttonEnable is clicked , then Enable HelyaAssist (enable button)
  79. buttonEnable:SetScript("OnClick", function(self, button, down)
  80. local playerName = UnitName("player")
  81.     HelyaAssistAddon.disabled = nil
  82.     HelyaAssistAddon.shown = nil
  83.     ReloadUI()
  84. end)
  85.  
  86.  
  87.  
  88. -- PLAYER_ENTERING_WORLD for Enable button
  89.  
  90. local function UpdateTicker()
  91.     if Ticker < 1 or not debuffexists then return end
  92.  
  93.     SendChatMessage((Ticker > 5) and MoveMessage or DispelMessage .. Ticker, "Yell", nil, name)
  94.     Ticker = Ticker - 1
  95.  
  96.     C_Timer.After((Ticker > 5) and 1.5 or 0.7, UpdateTicker)
  97. end
  98.  
  99. local function UNIT_AURA()
  100.     local name, _, _, _, _, duration, expires = UnitDebuff("player", TaintOfTheSea)
  101.    
  102.     if name then
  103.         if not debuffexists then
  104.             debuffexists = true --player just got the debuff
  105.             Ticker = 6
  106.             UpdateTicker()
  107.         end
  108.     else
  109.         debuffexists = false -- doesn't exist
  110.     end
  111. end
  112.  
  113. local eventframe = CreateFrame("Frame")
  114. if HelyaAssistAddon and HelyaAssistAddon.disabled then
  115.     MOD_TextFrame:Hide()
  116. else
  117.     eventframe:RegisterUnitEvent("UNIT_AURA", "player")
  118.     eventframe:SetScript("OnEvent", UNIT_AURA)
  119. end

.toc file
Lua Code:
  1. ## Interface: 70100
  2. ## Author: Lmannen (Ingame Name = Bishoop)
  3. ## Version: 1.0
  4. ## Title: HelyaAssist
  5. ## Notes: Inspired by Helya mythic! Will make timing with massdispell easier with targets affected by taint of the sea easier.
  6. ## DefaultState: enabled
  7.  
  8. ## SavedVariables: HelyaAssistAddon
  9. HelyaAssist.lua
  Reply With Quote
01-23-17, 01:49 PM   #36
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,903
Originally Posted by pas06 View Post
Fizzlemizz, feel free to look at my code in post 13, i don't have the biggest experience, but i feel like i did a good job with that code(after editing that post 5 times ).
You would have to UnregisterEvent("ENCOUNTER_END") in the ENCOUNTER_END function otherwise the message would fire every time any encounter ends after it's registered, otherwise it looks like it should work.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-23-17, 02:01 PM   #37
pas06
A Theradrim Guardian
Join Date: Apr 2009
Posts: 62
thats true, something is always missing
  Reply With Quote
01-23-17, 02:06 PM   #38
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Originally Posted by pas06 View Post
thats true, something is always missing
Do you know how? ^^ , otherwise great code!
best regards guys

Last edited by wille480 : 01-23-17 at 02:27 PM.
  Reply With Quote
01-23-17, 02:28 PM   #39
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,903
From the second block of code last posted.
Some things rearranged or removed for clarity. This enables/disables for ALL characters, would need some extra code for per character to work. Essentially, if the addon is faux disabled, the UNIT_AURA event is not registered.
Lua Code:
  1. local TaintOfTheSea     = GetSpellInfo(228054)
  2. local Ticker            = 0
  3. local MoveMessage       = "{moon} MOVE TO MOON {moon}"
  4. local DispelMessage     = "Dispell on {moon} in "
  5. local debuffexists      = false
  6. local titleFont = [=[Interface\Addons\HelyaAssist\fonts\accid___.ttf]=]
  7. local folder = "HelyaAssist"
  8. local ds = 0
  9.  
  10. -- Adds HelyaAssist to interface in addons
  11. local myAddon = {};
  12. myAddon.panel = CreateFrame( "Frame", "myAddonPanel", UIParent);
  13. myAddon.panel.name = "HelyaAssist";
  14. InterfaceOptions_AddCategory(myAddon.panel);
  15.  
  16. --Text in panel
  17. local MOD_TextFrame = CreateFrame("Frame", nil, myAddonPanel);
  18. MOD_TextFrame:ClearAllPoints();
  19. MOD_TextFrame:SetHeight(300);
  20. MOD_TextFrame:SetWidth(300);
  21. MOD_TextFrame:SetScript("OnUpdate", MOD_TextFrame_OnUpdate);
  22. MOD_TextFrame.text = MOD_TextFrame:CreateFontString(nil, "BACKGROUND", "PVPInfoTextFont");
  23. MOD_TextFrame.text:SetAllPoints();
  24. MOD_TextFrame:SetPoint("CENTER", -245, 260);
  25. MOD_TextFrameTime = 0;
  26. MOD_TextFrame.text:SetText('|cffffff00HelyaAssist');
  27. MOD_TextFrame.text:SetFont(titleFont, 19);
  28.  
  29. --Create the button (enable)
  30. local buttonEnable = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  31. buttonEnable:SetPoint("CENTER", -255,220)
  32. buttonEnable:SetWidth(80)
  33. buttonEnable:SetHeight(22)
  34. buttonEnable:SetText("Enabled")
  35. --If buttonEnable is clicked , then Enable HelyaAssist (enable button)
  36. buttonEnable:SetScript("OnClick", function(self, button, down)
  37. local playerName = UnitName("player")
  38.     HelyaAssistAddon.disabled = nil
  39.     HelyaAssistAddon.shown = nil
  40.     ReloadUI()
  41. end)
  42.  
  43. --Create the button (disable)
  44. local buttonDisable = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  45. buttonDisable:SetPoint("CENTER", -160,220)
  46. buttonDisable:SetWidth(80)
  47. buttonDisable:SetHeight(22)
  48. buttonDisable:SetText("Disabled")
  49.   --If mybutton2 is clicked, then disable HelyaAssist (disable button)
  50. buttonDisable:SetScript("OnClick", function(self, button, down)
  51.     local playerName = UnitName("player")
  52.     HelyaAssistAddon.disabled = true
  53.     HelyaAssistAddon.shown = nil
  54.     ReloadUI()
  55. end)
  56.  
  57.  
  58. local function UpdateTicker()
  59.     if Ticker < 1 or not debuffexists then return end
  60.     SendChatMessage((Ticker > 5) and MoveMessage or DispelMessage .. Ticker, "Yell", nil, name)
  61.     Ticker = Ticker - 1
  62.     C_Timer.After((Ticker > 5) and 1.5 or 0.7, UpdateTicker)
  63. end
  64.  
  65. local frame = CreateFrame("FRAME", "FooAddonFrame");
  66.  
  67. function frame:UNIT_AURA()
  68.     local name, _, _, _, _, duration, expires = UnitDebuff("player", TaintOfTheSea)
  69.     if name then
  70.         if not debuffexists then
  71.             debuffexists = true --player just got the debuff
  72.             Ticker = 6
  73.             UpdateTicker()
  74.         end
  75.     else
  76.         debuffexists = false -- doesn't exist
  77.     end
  78. end
  79.  
  80. function frame:PLAYER_ENTERING_WORLD(event, ...)
  81.     if not HelyaAssistAddon then
  82.         HelyaAssistAddon = {}
  83.     end
  84.     local playerName = UnitName("player")
  85.     if HelyaAssistAddon.disabled then
  86.         if not HelyaAssistAddon.shown then
  87.             HelyaAssistAddon.shown = true
  88.             print('|cffffff00HelyaAssist is now Disabled')
  89.         end
  90.         MOD_TextFrame:Hide()
  91.         buttonEnable:Enable()
  92.         buttonDisable:Disable()
  93.     else
  94.         if not HelyaAssistAddon.shown then
  95.             HelyaAssistAddon.shown = true
  96.             print('|cffffff00HelyaAssist is now Enable')
  97.         end
  98.         buttonDisable:Enable()
  99.         buttonEnable:Disable()
  100.         self:RegisterUnitEvent("UNIT_AURA", "player")
  101.         self:SetScript("OnEvent", UNIT_AURA)
  102.     end
  103.     self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  104. end
  105.  
  106. frame:SetScript("OnEvent", function(self, event, ...)
  107.         self[event](self, event, ...)
  108.     end)
  109. frame:RegisterEvent("PLAYER_ENTERING_WORLD");
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
01-23-17, 03:02 PM   #40
wille480
A Wyrmkin Dreamwalker
Join Date: Jan 2017
Posts: 56
Hey fizzle!
Your recent post with that code do not work. It will create two panels in interface -> addons aswell with the same name "HelyaAssist" and will print "HelyaAssist is now Enabled" two times in a row.

i only switched out second block and removed the second PLAYER_ENTERING_WORLD code from the above block.

Well this is the code i have so far. I remade it abit so it wont create two panels , basicly everything is the same from before only that now this code wont work
Lua Code:
  1. -- Run this code below if buttonEnable is on ("clicked") whatever, else ignore the code below.
  2. local function UpdateTicker()
  3.     if Ticker < 1 or not debuffexists then return end
  4.     SendChatMessage((Ticker > 5) and MoveMessage or DispelMessage .. Ticker, "Yell", nil, name)
  5.     Ticker = Ticker - 1
  6.     C_Timer.After((Ticker > 5) and 1.5 or 0.7, UpdateTicker)
  7. end
  8.  
  9. local frame = CreateFrame("FRAME", "FooAddonFrame");
  10.  
  11. function frame:UNIT_AURA()
  12.     local name, _, _, _, _, duration, expires = UnitDebuff("player", TaintOfTheSea)
  13.     if name then
  14.         if not debuffexists then
  15.             debuffexists = true --player just got the debuff
  16.             Ticker = 6
  17.             UpdateTicker()
  18.         end
  19.     else
  20.         debuffexists = false -- doesn't exist
  21.     end
  22. end


The buttons and stuff work but not the purpose of the addon itself, it will now not print "MOVE TO MOON" or do a dispell countdown if you get the debuff , regarding what button you press, will not work with buttonEnable on or buttonDisable.
This is the code i am talking about.
Lua Code:
  1. local TaintOfTheSea     = GetSpellInfo(228054)
  2. local Ticker            = 0
  3. local MoveMessage       = "{moon} MOVE TO MOON {moon}"
  4. local DispelMessage     = "Dispell on {moon} in "
  5. local debuffexists      = false
  6. local titleFont = [=[Interface\Addons\HelyaAssist\fonts\accid___.ttf]=]
  7. local folder = "HelyaAssist"
  8.  
  9. -- Adds HelyaAssist to interface in addons
  10. local myAddon = {};
  11. myAddon.panel = CreateFrame( "Frame", "myAddonPanel", UIParent);
  12. myAddon.panel.name = "HelyaAssist";
  13. InterfaceOptions_AddCategory(myAddon.panel);
  14.  
  15. --Create the button (enable)
  16. local buttonEnable = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  17. buttonEnable:SetPoint("CENTER", -255,220)
  18. buttonEnable:SetWidth(80)
  19. buttonEnable:SetHeight(22)
  20. buttonEnable:SetText("Enabled")
  21.  
  22. --Create the button (disable)
  23. local buttonDisable = CreateFrame("Button","mybutton", myAddon.panel, "UIPanelButtonTemplate")
  24. buttonDisable:SetPoint("CENTER", -160,220)
  25. buttonDisable:SetWidth(80)
  26. buttonDisable:SetHeight(22)
  27. buttonDisable:SetText("Disabled")
  28.  
  29. --Text in panel
  30. local MOD_TextFrame = CreateFrame("Frame", nil, myAddonPanel);
  31. MOD_TextFrame:ClearAllPoints();
  32. MOD_TextFrame:SetHeight(300);
  33. MOD_TextFrame:SetWidth(300);
  34. MOD_TextFrame:SetScript("OnUpdate", MOD_TextFrame_OnUpdate);
  35. MOD_TextFrame.text = MOD_TextFrame:CreateFontString(nil, "BACKGROUND", "PVPInfoTextFont");
  36. MOD_TextFrame.text:SetAllPoints();
  37. MOD_TextFrame:SetPoint("CENTER", -245, 260);
  38. MOD_TextFrameTime = 0;
  39. MOD_TextFrame.text:SetText('|cffffff00HelyaAssist');
  40. MOD_TextFrame.text:SetFont(titleFont, 19);
  41.  
  42.  --If mybutton2 is clicked, then disable HelyaAssist (disable button)
  43. buttonDisable:SetScript("OnClick", function(self, button, down)
  44.     local playerName = UnitName("player")
  45. --    DisableAddOn(folder, playerName)
  46.     HelyaAssistAddon.disabled = true
  47.     HelyaAssistAddon.shown = nil
  48.     ReloadUI()
  49. end)
  50.  
  51. -- PLAYER_ENTERING_WORLD for Disable button
  52.  
  53.  
  54.  
  55. --If buttonEnable is clicked , then Enable HelyaAssist (enable button)
  56. buttonEnable:SetScript("OnClick", function(self, button, down)
  57. local playerName = UnitName("player")
  58.     HelyaAssistAddon.disabled = nil
  59.     HelyaAssistAddon.shown = nil
  60.     ReloadUI()
  61. end)
  62.  
  63.  
  64.  
  65. -- PLAYER_ENTERING_WORLD for Enable button
  66. local function UpdateTicker()
  67.     if Ticker < 1 or not debuffexists then return end
  68.     SendChatMessage((Ticker > 5) and MoveMessage or DispelMessage .. Ticker, "Yell", nil, name)
  69.     Ticker = Ticker - 1
  70.     C_Timer.After((Ticker > 5) and 1.5 or 0.7, UpdateTicker)
  71. end
  72.  
  73. local frame = CreateFrame("FRAME", "FooAddonFrame");
  74.  
  75. function frame:UNIT_AURA()
  76.     local name, _, _, _, _, duration, expires = UnitDebuff("player", TaintOfTheSea)
  77.     if name then
  78.         if not debuffexists then
  79.             debuffexists = true --player just got the debuff
  80.             Ticker = 6
  81.             UpdateTicker()
  82.         end
  83.     else
  84.         debuffexists = false -- doesn't exist
  85.     end
  86. end
  87.  
  88. function frame:PLAYER_ENTERING_WORLD(event, ...)
  89.     if not HelyaAssistAddon then
  90.         HelyaAssistAddon = {}
  91.     end
  92.     local playerName = UnitName("player")
  93.     if HelyaAssistAddon.disabled then
  94.         if not HelyaAssistAddon.shown then
  95.             HelyaAssistAddon.shown = true
  96.             print('|cffffff00HelyaAssist is now Disabled')
  97.         end
  98.         MOD_TextFrame:Hide()
  99.         buttonEnable:Enable()
  100.         buttonDisable:Disable()
  101.     else
  102.         if not HelyaAssistAddon.shown then
  103.             HelyaAssistAddon.shown = true
  104.             print('|cffffff00HelyaAssist is now Enable')
  105.         end
  106.         buttonDisable:Enable()
  107.         buttonEnable:Disable()
  108.         self:RegisterUnitEvent("UNIT_AURA", "player")
  109.         self:SetScript("OnEvent", UNIT_AURA)
  110.     end
  111.     self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  112. end
  113.  
  114. frame:SetScript("OnEvent", function(self, event, ...)
  115.         self[event](self, event, ...)
  116.     end)
  117. frame:RegisterEvent("PLAYER_ENTERING_WORLD");

Last edited by wille480 : 01-23-17 at 03:06 PM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » button("OnClick") & PLAYER_ENTERING_WORLD


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off