+ Reply to Thread
Results 1 to 4 of 4

Thread: Frame event malfunction

  1. #1
    Rift Chaser Ferather's Avatar
    Join Date
    Jun 2011
    Posts
    341

    Default Frame event malfunction

    Found a bug that causes an error for unknown reasons, I have however found a fix.

    Results below:

    Code:
    	function I.Build.Modes()
    		for k,v in Pairs(I) do
    			if Match(k, "Meter") or Match(k, "Mode") then
    				I[k]:SetVisible(false)
    				I[k] = nil
    			end
    		end
    		
    		for i = 1, G.Modes do
    			local Text = String("  %0s  ", G.Mode[i])
    			local Meter = "Meter" .. i
    			local Mode = "Mode" .. i
    			local Number = 52 * i
    			
    			if Meter and not I[Meter] then
    				I[Mode] = UI.CreateFrame("Text", "Parser Mode" .. i, I.Parser)
    				I[Mode]:SetPoint("TOPRIGHT", I.Units, "TOPRIGHT", Number, -18)
    				I[Mode]:SetFontSize(14)
    				I[Mode]:SetWidth(48)
    				
    				I[Meter] = UI.CreateFrame("Text", "Parser Meter" .. i, I.Parser)
    				I[Meter]:SetPoint("TOPCENTER", I[Mode], "TOPCENTER", 0, 18)
    				I[Meter]:SetFontSize(14)
    			end
    			
    			function I[Mode].Event:LeftDown()
    				dump("Ran")
    			end
    			
    			I[Mode]:SetText(Text)
    		end
    		
    		I.Parser:SetWidth(I.Units:GetWidth() + 8 + (48 * G.Modes) + (4 * G.Modes))
    	end
    This will cause an error on addon load, making it un-usable, The fix:

    Code:
    	function I.Build.Modes()
    		for k,v in Pairs(I) do
    			if Match(k, "Meter") or Match(k, "Mode") then
    				I[k]:SetVisible(false)
    				I[k] = nil
    			end
    		end
    		
    		for i = 1, G.Modes do
    			local Text = String("  %0s  ", G.Mode[i])
    			local Meter = "Meter" .. i
    			local Mode = "Mode" .. i
    			local Number = 52 * i
    			local Frame = false
    			
    			if Meter and not I[Meter] then
    				I[Mode] = UI.CreateFrame("Text", "Parser Mode" .. i, I.Parser)
    				I[Mode]:SetPoint("TOPRIGHT", I.Units, "TOPRIGHT", Number, -18)
    				I[Mode]:SetFontSize(14)
    				I[Mode]:SetWidth(48)
    				
    				I[Meter] = UI.CreateFrame("Text", "Parser Meter" .. i, I.Parser)
    				I[Meter]:SetPoint("TOPCENTER", I[Mode], "TOPCENTER", 0, 18)
    				I[Meter]:SetFontSize(14)
    				
    				Frame = I[Mode]
    			end
    			
    			function Frame.Event:LeftDown()
    				dump("Ran")
    			end
    			
    			I[Mode]:SetText(Text)
    		end
    		
    		I.Parser:SetWidth(I.Units:GetWidth() + 8 + (48 * G.Modes) + (4 * G.Modes))
    	end
    The Difference:

    Code:
    			local Frame = false  <---- Had to localize the table
    			
    			if Meter and not I[Meter] then
    				I[Mode] = UI.CreateFrame("Text", "Parser Mode" .. i, I.Parser)
    				I[Mode]:SetPoint("TOPRIGHT", I.Units, "TOPRIGHT", Number, -18)
    				I[Mode]:SetFontSize(14)
    				I[Mode]:SetWidth(48)
    				
    				I[Meter] = UI.CreateFrame("Text", "Parser Meter" .. i, I.Parser)
    				I[Meter]:SetPoint("TOPCENTER", I[Mode], "TOPCENTER", 0, 18)
    				I[Meter]:SetFontSize(14)
    				
    				Frame = I[Mode]  <---- Had to localize the table
    			end
    			
    			function Frame.Event:LeftDown()
    				dump("Ran")
    			end
    Last edited by Ferather; 10-24-2014 at 02:33 PM.

  2. #2
    Rift Chaser Ferather's Avatar
    Join Date
    Jun 2011
    Posts
    341

    Default Insult to Injury

    Doing: dump(I[Mode].Event)
    Dumps the correct table

    Doing: function I[Mode].Event:LeftDown()
    Breaks the addon

  3. #3
    Plane Touched
    Join Date
    Feb 2012
    Posts
    228

    Default

    Have you tried using the new event system?

  4. #4
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    It's a lua thing I think. It's the : and the function definition that is causing your problems.

    This should work, and avoid the need for the temp values:

    I[Mode].Event.LeftDown = function(self)
    dump("Ran")
    end
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts