Quantcast
Block Function CastSpellByName - WoWInterface
Thread Tools Display Modes
08-29-20, 11:14 AM   #1
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 316
Block Function CastSpellByName

I have a professions button that i use to open prof1 and prof2 when ever i leftclick for prof1 i get this:
Code:
9x [ADDON_ACTION_FORBIDDEN] AddOn 'BasicUI' tried to call the protected function 'CastSpellByName()'.
[string "@!BugGrabber\BugGrabber.lua"]:519: in function <!BugGrabber\BugGrabber.lua:519>
[string "=[C]"]: in function `CastSpellByName'
[string "@BasicUI\Modules\Datapanel.lua"]:1763: in function <BasicUI\Modules\Datapanel.lua:1752>
Yet if i right click the same button it opens prof2 like it is suppose to.

Here is the code im using:
Code:
		proPlugin:SetScript("OnMouseDown",function(self, button)
			local prof1, prof2, _, _, _ = GetProfessions()
			if button == "LeftButton" then
				if prof1 then	
					CastSpellByName((GetProfessionInfo(prof1)))
				else
					print('|cff33ff99BasicUI:|r |cffFF0000No Profession Found!|r')
				end
			elseif button == 'MiddleButton' then
				ToggleSpellBook(BOOKTYPE_PROFESSION)	
			elseif button == "RightButton" then
				if prof2 then
					CastSpellByName((GetProfessionInfo(prof2)))
				else
					print('|cff33ff99BasicUI:|r |cffFF0000No Profession Found!|r')
				end
			end
		end)
Why does the leftbutton throw and error yet the middle and right do not?
  Reply With Quote
08-29-20, 11:19 AM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 500
Try using CastSpell(prof1) instead. GetProfessions() returns spell book indexes which can be fed straight into CastSpell().
  Reply With Quote
08-29-20, 11:35 AM   #3
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 316
Originally Posted by Kanegasi View Post
Try using CastSpell(prof1) instead. GetProfessions() returns spell book indexes which can be fed straight into CastSpell().
Nope, i change it to the above and got this error:
Code:
1x BasicUI\Modules\Datapanel.lua:1756: CastSpell(): Invalid spell slot
[string "=[C]"]: in function `CastSpell'
[string "@BasicUI\Modules\Datapanel.lua"]:1756: in function <BasicUI\Modules\Datapanel.lua:1752>

Locals:
(*temporary) = 7
  Reply With Quote
08-29-20, 03:57 PM   #4
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 500
I tested the code you provided and all three buttons work for me. The left and right buttons even work in combat, but the middle button does not. I used a piece of a weakaura I have for the button.

Lua Code:
  1. local proPlugin=CreateFrame("Button","proPlugin",UIParent,"ActionButtonTemplate,SecureActionButtonTemplate")
  2. proPlugin:SetSize(32,32)
  3. proPlugin.icon:SetTexture(135912)
  4. proPlugin:SetPoint("CENTER")
  5. proPlugin:EnableMouse(true)
  6. proPlugin:SetScript("OnMouseDown",function(self, button)
  7.     local prof1, prof2, _, _, _ = GetProfessions()
  8.     if button == "LeftButton" then
  9.         if prof1 then  
  10.             CastSpellByName((GetProfessionInfo(prof1)))
  11.         else
  12.             print('|cff33ff99BasicUI:|r |cffFF0000No Profession Found!|r')
  13.         end
  14.     elseif button == 'MiddleButton' then
  15.         ToggleSpellBook(BOOKTYPE_PROFESSION)   
  16.     elseif button == "RightButton" then
  17.         if prof2 then
  18.             CastSpellByName((GetProfessionInfo(prof2)))
  19.         else
  20.             print('|cff33ff99BasicUI:|r |cffFF0000No Profession Found!|r')
  21.         end
  22.     end
  23. end)
  Reply With Quote
08-30-20, 07:51 AM   #5
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 316
Originally Posted by Kanegasi View Post
I tested the code you provided and all three buttons work for me. The left and right buttons even work in combat, but the middle button does not. I used a piece of a weakaura I have for the button.
Then it has to be something in my main UI beacuse i still get the same popup:

  Reply With Quote
08-30-20, 10:33 AM   #6
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 458
Originally Posted by cokedrivers View Post
Then it has to be something in my main UI beacuse i still get the same popup:

Have you tried disabling addons and re enabling them one at a time till you find the offending addon?
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Block Function CastSpellByName

Thread Tools
Display Modes

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