Thread Tools Display Modes
08-16-15, 02:56 PM   #21
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Readability? This line will be readable in two years when blizz changes it's order again ...
Lua Code:
  1. local self, event, timestamp, type, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = ...
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
08-16-15, 05:34 PM   #22
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
So many ideas on my head :U

  Reply With Quote
08-17-15, 08:02 PM   #23
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by suicidalkatt View Post
So many ideas on my head :U
"Ideas." Sure, that's totally what that is.
__________________
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
08-17-15, 08:56 PM   #24
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Originally Posted by Phanx View Post
"Ideas." Sure, that's totally what that is.
I like your profile icon, it makes me this.
  Reply With Quote
08-19-15, 08:08 AM   #25
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by suicidalkatt View Post
I like your profile icon, it makes me this.
Haha, how high is that cat?

My icon is actually a bad cell phone photo of an actual cat statue I have in my house. I've had it forever but just got it back out of storage and thought it would make a good avatar, even though I couldn't manage to get a picture of it that didn't make it look slightly derpy.
__________________
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
08-19-15, 09:49 AM   #26
Endzeit
A Deviate Faerie Dragon
Join Date: Aug 2015
Posts: 12
new problem with a table i think the table is not the problem this time.. i think it is the event.. i tryed eyverthing for hours but i dont get it.

no print("TEST")


Lua Code:
  1. local bloodlust = { 2825, 32182, 90355, 160452, 80353, 1459, };
  2. local a = CreateFrame( "Frame" )
  3. a:RegisterEvent( "COMBAT_LOG_EVENT_UNFILTERED" )
  4. a:SetScript( "OnEvent", function( self, event, ...)
  5.     function a:COMBAT_LOG_EVENT_UNFILTERED(e, timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...)
  6.     if (event == "SPELL_AURA_APPLIED") and (destName == UnitName("player")) then
  7.         local spellId, spellName, spellSchool, auraType = ...;
  8.         for _,v in pairs(bloodlust) do
  9.             if v == spellId then
  10.                 print("TEST")
  11.             end
  12.         end
  13.     end
  14. end
  15. end )


EDIT:
i found a possible solution:
Lua Code:
  1. local bloodlust = { 2825, 32182, 90355, 160452, 80353, 1459, };
  2. local a = CreateFrame( "Frame" )
  3. a:RegisterEvent( "COMBAT_LOG_EVENT_UNFILTERED" )
  4. a:SetScript( "OnEvent", function( self, event, timestamp, type, hideCaster, sourceGUID, sourceName, sourceFlags, sourceFlags2, destGUID, destName, destFlags, destFlags2, ...)
  5.     if (type == "SPELL_AURA_APPLIED") and (destName == UnitName("player")) then
  6.     local spellId, spellName, spellSchool, auraType = ...;
  7.         for _,v in pairs(bloodlust) do
  8.             if v == spellId then
  9.                 print("TEST")
  10.             end
  11.         end
  12.     end
  13. end )

is this code okay?

Last edited by Endzeit : 08-19-15 at 10:21 AM.
  Reply With Quote
08-19-15, 12:08 PM   #27
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Rather than looping over an indexed table on every aura event, just use a hash table instead:
Code:
local bloodlust = { [2825]=1, [32182]=1, [90355]=1, [160452]=1, [80353]=1, [1459]=1 }
Then you can just do a simple table lookup inside the event handler:
Code:
if bloodlust[spellId] then
(Note that the value of each entry being 1 is irrelevant; any non-nil/false value will do. 1 is just nice and short.)

Also, looking up UnitName("player") on every aura event is pretty wasteful. Just do it once and store it in a variable outside of the event handler:
Code:
local PLAYER = UnitName("player")
...then refer to that variable in the event handler:
Code:
if (type == "SPELL_AURA_APPLIED") and (destName == PLAYER) then
__________________
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

WoWInterface » Developer Discussions » Lua/XML Help » Problems with Big Tables

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