Thread Tools Display Modes
07-04-13, 03:06 PM   #1
Nischi
A Murloc Raider
Join Date: Jun 2007
Posts: 4
Get spell slot from Actionbar

Hello everyone

I've been sitting alone with this problem for a while now, and I just can't solve it.

I have a really simple function that is supposed to loop through all the 120 slots on the actionbar, using the GetActionInfo procedure and store the found spells slot number in an array.


I get most of the spell slot numbers as expected, but there are some certain spells, that even tho placed on my actionbar does not get any return value other than "nil". Spells such as the Druids "Heart of the Wild", "Pounce", "Savage Roar", and the Shamans "Purify Spirit"

Looks kinda like this:

function MyNoobAddon:ACTIONBAR_SLOT_CHANGED(slot)
local action_Type, action_ID, action_subType, action_spellID = GetActionInfo(slot)
if action_ID then Spell_ID_Slots[action_ID] = slot end

Where Spell_ID_Slots[action_ID] returns nil for above said spells.

Thanks for taking you're time

Regards,
Nischi
  Reply With Quote
07-04-13, 03:12 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Please post your entire, actual code, not a snippet of "kinda like" code.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
07-04-13, 03:37 PM   #3
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Lua Code:
  1. function EventFrame:ACTIONBAR_SLOT_CHANGED(slot)
  2.     print(slot, GetActionInfo(slot))
  3. end
  4. EventFrame:RegisterEvent('ACTIONBAR_SLOT_CHANGED')
This works fine with some of the spells you said weren't working so maybe this isn't the part that's failing.
  Reply With Quote
07-05-13, 02:28 AM   #4
Nischi
A Murloc Raider
Join Date: Jun 2007
Posts: 4
Originally Posted by Phanx View Post
Please post your entire, actual code, not a snippet of "kinda like" code.
Oh okay, sorry. I should mention that this code project I'm working on is an update of the addon called SpellLight, I've tried to get in contact with the author for more than 1 year now without any reply. So I've been keeping it for my personal use only.

Anyway, it looks like this:

Code:
function My_New_Addon:UpdateSpellBook()

	for slot=1,120 do self:ACTIONBAR_SLOT_CHANGED(slot) end
	
	if self:PLAYER_REGEN_ENABLED(true) then
		if SpellBookSpellIconsFrame:IsShown() then for id=1,12 do SpellButton_UpdateButton(_G['SpellButton'..id]) end end
	end
end

function My_New_Addon:ACTIONBAR_SLOT_CHANGED(slot)
	local action_Type, action_ID, action_subType, action_spellID = GetActionInfo(slot)

		if action_ID then idslots[action_ID] = slot end
		
		actionids[slot] = action_ID
		self:UpdateSpellBook()
end

function My_New_Addon:ACTIONBAR_HIDEGRID()
	self:UpdateSpellBook(true)
end

function My_New_Addon:SpellButton_UpdateButton(frame)
	local name = frame:GetName()

	frame:SetAlpha(1)
	_G[name..'IconTexture']:SetDesaturated(false)
	_G[name..'IconTexture']:SetVertexColor(1,1,1)

	
	local Spellbook_slot = SpellBook_GetSpellBookSlot(frame)
	
	local color_The_Slot_id = Spellbook_slot and select(2, GetSpellBookItemInfo(Spellbook_slot, BOOKTYPE_SPELL))

	print (color_The_Slot_id)
        -- !! This prints the Spell ID found in chat.
	
	print (idslots[color_The_Slot_id])
        -- !! This prints the corresponding Slot for that ID found in chat. This is where it goes wrong.

	if idslots[color_The_Slot_id] then
		frame:SetAlpha(.4)
		_G[name..'IconTexture']:SetDesaturated(true)
		_G[name..'IconTexture']:SetVertexColor(0.4,0.4,0.4)
	end
		
	if IsPassiveSpell(Spellbook_slot, BOOKTYPE_SPELL) then
		frame:SetAlpha(.5)
		_G[name..'IconTexture']:SetDesaturated(true)
		_G[name..'IconTexture']:SetVertexColor(0.8,0.8,0.8)
	end
end

Last edited by Nischi : 07-05-13 at 05:07 AM.
  Reply With Quote
07-05-13, 02:57 AM   #5
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
You can use [code]your code here[/code] tags to make your code easier to read when posting on this forum or for larger code snippets a link to a paste or an attachment.

Since you're likely to be posting more questions or answers down the road, just helping get the trivial stuff that will make the exchange easier out of the way

Last edited by Dridzt : 07-05-13 at 03:02 AM.
  Reply With Quote
07-05-13, 07:29 AM   #6
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
You might also be interested in the addon Spell Search which reorders the spellbook to put unbound abilities first.

It has its own issues with trying to navigate the spellbook in combat that I've been too lazy to fix but feel free to rip off some of the code.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Get spell slot from Actionbar


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