Thread Tools Display Modes
05-25-10, 05:35 AM   #1
mentalnutsy
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 47
Why cant i print spell info?

I know I am probably missing something obvious but cant work it out. Below is the code I am working with. The function is being called (highlighted below) but it just keeps returning nill.
(I'm not that good at lua and still learning so please simplify as much as possible thanks.)

Code:
NuttyWarAnnounce = LibStub("AceAddon-3.0"):NewAddon("NuttyWarAnnounce", "AceConsole-3.0", "AceEvent-3.0")

function NuttyWarAnnounce:OnInitialize()
    -- Called when the addon is loaded
end

function NuttyWarAnnounce:OnEnable()
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end

function NuttyWarAnnounce:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, subevent, srcGUID, srcName, srcflags, dstGUID, dstname, dstflags, spellID)
	if UnitGUID("player") == srcGUID then
		if subevent == "SPELL_AURA_APPLIED" then
			if NuttyWarAnnounce.spellids.shouts[spellID] then			
				NuttyWarAnnounce:sendmessage()
				else if NuttyWarAnnounce.spellids.alerts[spellID] then
				NuttyWarAnnounce:spellcastcheck()
				end
			end
		end
		
		if subevent == "SPELL_AURA_REMOVED" then
			if NuttyWarAnnounce.spellids.shouts[spellID] then
				NuttyWarAnnounce:sendmessage()
			end 
		end
	end
end

	function NuttyWarAnnounce:spellcastcheck()
	print(spellid) --not working
	end
	
	function NuttyWarAnnounce:sendmessage()
	print ("test")
	end
NuttyWarAnnounce.spellids = {
	shouts= {
				[43308] = "find fish", --used for testing purposes--
				[6673] = "Battle Shout",
				[5242] = "Battle Shout",
				[6192] = "Battle Shout",
				[11549] = "Battle Shout",
				[11550] = "Battle Shout",
				[11551] = "Battle Shout",
				[25289] = "Battle Shout",
				[2048] = "Battle Shout",
				[47436] = "Battle Shout",

				[47440] = "Commanding Shout",
				[469] = "Commanding Shout",
				[47439] = "Commanding Shout",
			},
	alerts = {

				[1161] = "Challenging Shout",
				[871] = "Shied Wall",
				[64382] = "Shattering Throw",
				[12976] = "Last Stand",
				[676] = "Disarm",
			},
	taunts = {
				[355] = "Taunt",
				[694] = "Mocking Blow",
			},
}

Last edited by mentalnutsy : 05-25-10 at 05:37 AM. Reason: typo in thread name
  Reply With Quote
05-25-10, 05:39 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,927
spellid doesn't contain a value for that function.

In another function it is stored in a temporary variable of spellID but then that information is lost when you leave the function it is in unless you pass it to another function to work with which you aren't.

Look at the highlighted code and change appropriately and it should work.

Code:
function NuttyWarAnnounce:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, subevent, srcGUID, srcName, srcflags, dstGUID, dstname, dstflags, spellID)
	if UnitGUID("player") == srcGUID then
		if subevent == "SPELL_AURA_APPLIED" then
			if NuttyWarAnnounce.spellids.shouts[spellID] then			
				NuttyWarAnnounce:sendmessage()
				else if NuttyWarAnnounce.spellids.alerts[spellID] then
				NuttyWarAnnounce:spellcastcheck(spellID)
				end
			end
		end
		
		if subevent == "SPELL_AURA_REMOVED" then
			if NuttyWarAnnounce.spellids.shouts[spellID] then
				NuttyWarAnnounce:sendmessage()
			end 
		end
	end
end

	function NuttyWarAnnounce:spellcastcheck(spellid)
	print(spellid) --not working
	end
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
05-25-10, 05:44 AM   #3
mentalnutsy
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 47
Thank you worked a treat
Just a thought would it be possible to do the same thing with GetSpellLink? as i tryed that also and had no luck are there diferent steps i need to take.

Last edited by mentalnutsy : 05-25-10 at 05:54 AM.
  Reply With Quote
05-25-10, 06:14 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,927
Yes, it should work the same. Just use the right variable dependant on where you use the function:

link = GetSpellLink(spellId or spellName)

EG.
if spellID is what is last used then link = GetSpellLink(spellID)
or if spellid is the last value used then link = GetSpellLink(spellid)
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
05-25-10, 06:26 AM   #5
mentalnutsy
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 47
Thank you for yer help.
I had been wondering what i was missing all morning and tbh google/wiki have a habit of going into way to much detail causing more confushion rather than actually helping for newbs like myself .

You made what i needed to do clear and understandable thank you.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Why cant i print spell info?

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