View Single Post
02-23-23, 06:52 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Cancel a spell cast

Hi all

I have a list of spells, (hearthstones), that I want to cancel during it's cast.
This is a secure action so I have set up the button as a SecureActionButtonTemplate.
Lua Code:
  1. if event == "UNIT_SPELLCAST_SENT" then
  2.     unit, _, _, spellID = ...
  3.     if unit == "player" then
  4.         for k, v in pairs(hearthtonesList) do
  5.             if spellID == v then
  6.                 print("found") -- debug --
  7.                 b.hiddenSpellStopButton:Click()
  8.             end
  9.         end
  10.     end
  11. end
  12.  
  13. b.hiddenSpellStopButton = CreateFrame("Button", nil, nil, "SecureActionButtonTemplate")
  14. b.hiddenSpellStopButton:RegisterForClicks("AnyDown")
  15. b.hiddenSpellStopButton:SetAttribute("type", "macro")
  16. b.hiddenSpellStopButton:SetAttribute("macrotext", "/stopcasting")
  17. b.hiddenSpellStopButton:SetScript(
  18.     "OnClick",
  19.     function()
  20.         print("here i am") -- debug --
  21.     end
  22. )
  23. b:RegisterEvent("UNIT_SPELLCAST_SENT")
I get both of the prints, so I can confirm that the button does click yet the spell does not stop the cast.

I have been banging away for the last few days trying to get this working.

Is there a way to stop a cast?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote