Thread Tools Display Modes
04-03-12, 01:11 AM   #1
pedropacan
A Murloc Raider
Join Date: Apr 2012
Posts: 5
Announcing addon not working as expected

Original Thread - http://www.mmo-champion.com/threads/...ng-as-expected
little about a problem: i have code for announce in chat pvp trinket/wotf but i get problem with spam (over10 msg in one sec about use) when i playing and my addon get over4mb memory.
my lua file - www.pastebin.com/vVsif26G
Thx
  Reply With Quote
04-03-12, 01:36 AM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
The size might be caused by creating new functions in your onevent handlers.
Create the function outside ...

Lua Code:
  1. local function dummy() end
...
Lua Code:
  1. MultiBarBottomRight.SetPoint = dummy

Edit:
Another problem is that your functions use very generic names (db) while being global . Thats extremly dangerous for stability.
Edit 2:
Your trinket OnEvent creates a table for every event and this sums up quickly and is cleared only on the next garbage collect.
Again it would make sense to have it created outside so that it is reused.
__________________
The cataclysm broke the world ... and the pandas could not fix it!

Last edited by Rilgamon : 04-03-12 at 01:47 AM.
  Reply With Quote
04-03-12, 04:27 AM   #3
pedropacan
A Murloc Raider
Join Date: Apr 2012
Posts: 5
did not quite understand about the dummy.
this ?
Lua Code:
  1. local function dummy() end
  2.         MultiBarBottomLeft:ClearAllPoints()
  3.         MultiBarBottomLeft:SetPoint("BOTTOMLEFT",ActionButton1,"TOPLEFT",0,6)
  4.         MultiBarBottomLeft.SetPoint = dummy
  5.         MultiBarBottomRight:ClearAllPoints()
  6.         MultiBarBottomRight:SetPoint("BOTTOMLEFT",ActionBarDownButton,"TOPLEFT",9.2,19)
  7.         MultiBarBottomRight.SetPoint = dummy
  8.         FocusFrame:ClearAllPoints()
  9.         FocusFrame:SetPoint("CENTER", TargetFrame, "CENTER", 0, -236)
  10.         FocusFrame.SetPoint = dummy
  11.         PetActionBarFrame:ClearAllPoints()
  12.         PetActionBarFrame:SetPoint("BOTTOMLEFT",ActionButton1,"TOPLEFT",-7,46.8)
  13.         MultiBarLeft:ClearAllPoints()
  14.         MultiBarLeft:SetPoint("BOTTOMRIGHT", UIParent,-43,86)
  15.         MultiBarLeft.SetPoint = dummy
  16.         MultiBarRight:ClearAllPoints()
  17.         MultiBarRight:SetPoint("BOTTOMRIGHT", UIParent,-1,86)
  18.         MultiBarRight.SetPoint = dummy
  19.         ShapeshiftBarFrame:ClearAllPoints()
  20.         ShapeshiftBarFrame:SetPoint("BOTTOM", UIParent, "BOTTOM", -473, 86)
  21.         ShapeshiftBarFrame:SetPoint = dummy
i tried to use
Lua Code:
  1. local spellIds = {
  2.     [42292] = "SPELL_CAST_SUCCESS",
  3.     [7744] = "SPELL_CAST_SUCCESS",
  4. };
  5.  
  6. local f = CreateFrame("frame");
  7. f:SetScript("OnEvent", function(self, event, ...) f[event](f, ...); end);
  8. f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
  9.  
  10.  
  11.  
  12. function f:COMBAT_LOG_EVENT_UNFILTERED(...)
  13.     local _, event, _, sourceGuid, _, _, _, _, _, _, _, spellId, spellName = select(1, ...);
  14.     if ( sourceGuid == UnitGUID("player") and event == spellIds[spellId] ) then
  15.         if ( GetNumPartyMembers() > 0 ) then -- not sure about returns
  16.             SendChatMessage(spellName.." used!", "PARTY");
  17.         end
  18.     end
  19. end
spam not stopping in both cases and addon memory 50kb~

Last edited by pedropacan : 04-03-12 at 04:30 AM.
  Reply With Quote
04-03-12, 04:35 AM   #4
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
To place the dummy-function outside make sure it is above your SetScript.

Lua Code:
  1. local function dummy() end
  2. a:SetScript("OnEvent",function(self,event)
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
04-03-12, 04:48 AM   #5
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
I'm not sure about the spam. I'd just add a delay roughly your spells duration (100ms) or even the cd (2min) before you send the message again.
Lua Code:
  1. local nextStamp = 0
  2. function f:COMBAT_LOG_EVENT_UNFILTERED(...)
  3.     local _, event, _, sourceGuid, _, _, _, _, _, _, _, spellId, spellName = select(1, ...);
  4.     if ( sourceGuid == UnitGUID("player") and event == spellIds[spellId] ) then
  5.         if ( GetNumPartyMembers() > 0 ) then -- not sure about returns
  6.             if ( nextStamp < GetTime()) then
  7.                   SendChatMessage(spellName.." used!", "PARTY");
  8.                   nextStamp = GetTime() + 0.1
  9.             end
  10.         end
  11.     end
  12. end
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
04-03-12, 04:59 AM   #6
pedropacan
A Murloc Raider
Join Date: Apr 2012
Posts: 5
your version doesn't work nothing announces
  Reply With Quote
04-09-12, 08:14 AM   #7
pedropacan
A Murloc Raider
Join Date: Apr 2012
Posts: 5
up. problem isn't solved
  Reply With Quote
04-09-12, 10:31 AM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Post your current code. I don't understand why people always think we can tell them what's wrong with their code without looking at it.
  Reply With Quote
04-09-12, 10:17 PM   #9
pedropacan
A Murloc Raider
Join Date: Apr 2012
Posts: 5
sorry. http://pastebin.com/7Pcbqk2E
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Announcing addon not working as expected


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