• 0

    posted a message on BG Queue for groups
    I have made your addon. Let me know if you need help setting up the .toc and stuff.

    PVPFrameLeftButton:SetScript("OnClick",
    	function(self, button, down)
    		if ( ((GetNumPartyMembers() > 0) or (GetNumRaidMembers() > 0)) and IsPartyLeader() ) then
    			StaticPopup_Show("CONFIRM_ACCEPT_SOLO_PVP_QUEUE")
    		else
    			PVPFrame_JoinClicked()
    		end
    	end)
    
    StaticPopupDialogs["CONFIRM_ACCEPT_SOLO_PVP_QUEUE"] = {
    	text = "You are in a group, are you sure you want to join solo?",
    	button1 = "Yes",
    	button2 = "No",
    	OnAccept = function()
    		PVPFrame_JoinClicked()
    	end,
    	timeout = 0,
    	whileDead = true,
    	hideOnEscape = true,
    }
    Posted in: Addon Ideas
  • 0

    posted a message on Tables and garbage memory
    Quote from Arkayenro
    what does this give you?

    It printed 76. I also added the collect garbage before the memory updates and still 76.

    I also tried removing the local t = {} from my last post like this

    collectgarbage()
    UpdateAddOnMemoryUsage()
    print(GetAddOnMemoryUsage("NewAddon")*1024)
    collectgarbage()
    UpdateAddOnMemoryUsage()
    print(GetAddOnMemoryUsage("NewAddon")*1024)


    and got:

    508
    508

    So just by adding in local t = {} increases by 76 bytes. Oh well, I was hoping I could measure to that level of precision, but I guess it's really not that important.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tables and garbage memory
    Ok, so I did this

    collectgarbage()
    UpdateAddOnMemoryUsage()
    print(GetAddOnMemoryUsage("NewAddon")*1024)
    local t = {}
    collectgarbage()
    UpdateAddOnMemoryUsage()
    print(GetAddOnMemoryUsage("NewAddon")*1024)


    and got

    528
    604

    Or a difference of 76. How do I account for the temporary strings to get a difference of 40?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Using restricted environment in SecureHandler
    Quote from Xchg
    btn:Execute([[
    		t = table.new()
    		n = 0
    	]])

    Is the table in the restricted environment specific to me or is it shared with other stuff in the restricted environment? I might have to change this one if it's shared.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Using restricted environment in SecureHandler
    Yeah, I keep things global when testing so I can make changes to them at the chat frame so I don't have to reload my ui every time. Here is what I ended up using for my target healers addon.

    	local btn = CreateFrame("Button", "healers", UIParent, "SecureActionButtonTemplate,SecureHandlerMouseUpDownTemplate")
    	btn:RegisterForClicks("AnyDown")
    	btn:SetAttribute("type", "macro")
    
    	btn:Execute([[
    		t = table.new()
    		n = 0
    	]])
    
    	SecureHandlerWrapScript(btn, "OnClick", btn,  [[
    		if #t == 0 then
    			self:SetAttribute("macrotext", nil)
    		else
    			n = n % #t + 1
    			self:SetAttribute("macrotext", "/tar "..t[n])
    		end	
    	]])


    This will cycle through the list of healers and update the macrotext to target the next healer in the list. I then clear the table when I leave combat and repopulate it with the list of known healers using something like this:

    	if not UnitAffectingCombat("player") then
    		btn:Execute("table.wipe(t) n = 0")
    		for i=1, #healers
    			btn:Execute("table.insert(t, '"..healers[i].."')")
    		end
    	end
    Posted in: Lua Code Discussion
  • 0

    posted a message on Using restricted environment in SecureHandler
    Yeah, I was actually doing the down/up test this morning, which is what brought me to your post. I was hoping to learn more about secure handlers. This is what I originally had:

    btn = CreateFrame("Button", "myButton", UIParent, "SecureActionButtonTemplate,SecureHandlerMouseUpDownTemplate")
    btn:SetWidth(48)
    btn:SetHeight(48)
    t = btn:CreateTexture()
    t:SetTexture("Interface\\ICONS\\Spell_Nature_HealingTouch")
    t:SetAllPoints()
    btn:SetPoint("TOP", 0, 0)
    btn:RegisterForClicks("AnyDown", "AnyUp")
    btn:SetAttribute("type", "spell")
    
    btn:SetAttribute("_onmousedown", [[
    	print("down", button)
    	self:SetAttribute("spell", "Blessing of Kings")
    ]])
    btn:SetAttribute("_onmouseup", [[
    	print("up", button)
    	self:SetAttribute("spell", "Blessing of Might")
    ]])
    Posted in: Lua Code Discussion
  • 0

    posted a message on Using restricted environment in SecureHandler
    So I'm fairly new and have been trying to learn how secure templates work, as well. I've been using the stuff I found on wowwiki to see what I can do inside a secure environment. This may not be terribly helpful, but it's what I've learned so far.

    btn = CreateFrame("Button", "myButton", UIParent, "SecureActionButtonTemplate,SecureHandlerMouseUpDownTemplate")
    btn:SetWidth(48)
    btn:SetHeight(48)
    t = btn:CreateTexture()
    t:SetTexture("Interface\\ICONS\\Spell_Nature_HealingTouch")
    t:SetAllPoints()
    btn:SetPoint("TOP")
    btn:RegisterForClicks("AnyDown")
    btn:SetAttribute("type", "spell")
    
    SecureHandlerWrapScript(btn, "OnClick", btn,  [[
    	if PlayerCanAssist("target") then
    		self:SetAttribute("spell", "Rejuvenation")
    	else
    		self:SetAttribute("spell", "Moonfire")
    	end
    ]])
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tables and garbage memory
    No this is interesting, I would like to be able to see and compare the memory usage of doing something two different ways. So just to test, I created a new addon and have this in the lua file:

    UpdateAddOnMemoryUsage()
    print(GetAddOnMemoryUsage("NewAddon")*1024)
    t = {}
    UpdateAddOnMemoryUsage()
    print(GetAddOnMemoryUsage("NewAddon")*1024)


    When I login I see:
    848
    948

    So creating the table used 100 bytes of memory. I had read on wowwiki a few weeks ago about memory sizes and wanted to know how to measure it. But it says creating a new empty table consumes 40 bytes?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tables and garbage memory
    Quote from Showside
    This creates 40KB per click.


    How does one measure one's memory usage?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Help with setting in my addon
    I'm far from an expert, but I think you want ADDON_LOADED instead of VARIABLES_LOADED. From what I understand, VARIABLES_LOADED is for Blizzard variables, not your addon's. ADDON_LOADED and it's first argument for your addon's name is how you know when your addon and its variables have been loaded.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Interface Addon Kit
    Or whatever the latest version was before the patch, 3.3.5 or whatever.

    I think this is what I'm looking for, thanks!
    Posted in: Lua Code Discussion
  • 0

    posted a message on Interface Addon Kit
    Is the old v3.5 interface addon kit available anywhere? I downloaded the new 4.0.1 version and deleted the old one.
    Posted in: Lua Code Discussion
  • 0

    posted a message on loadstring
    Ah, I see

    SLASH_SCRIPT1 = "/script";
    SLASH_SCRIPT2 = "/run";
    SLASH_SCRIPT3 = "/script";
    SLASH_SCRIPT4 = "/run";


    SlashCmdList["SCRIPT"] = function(msg)
    	RunScript(msg);
    end
    Posted in: Lua Code Discussion
  • 0

    posted a message on GetSpellTexture type function for buffs
    How does select work? I'm reading http://www.lua.org/pil/5.2.html and it says select is defined as:

        function select (n, ...)
          return arg[n]
        end
    


    Is this creating a table 'arg' and indexing 'n'? Is WoW select different?
    Posted in: Lua Code Discussion
  • 0

    posted a message on loadstring
    Last week I had created a large multi-line editbox that I could copy paste large blocks of code to run in-game for testing. I was getting tired of running everything as one line through the chat frame. This was before I learned about WoWLua, but I'm still using my editbox as a learning tool plus I can customize it.

    My question is, I am using loadstring to create and run the function like this:

    loadstring(EditBox:GetText())()


    This creates a new function in memory each time. With my recent reprimand about creating garbage, would it be more efficient to use the macro editbox instead? Such as:

    local cmd = "/run "..EditBox:GetText()
    MacroEditBox:SetText(cmd)
    ChatEdit_SendText(MacroEditBox)
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.