• 0

    posted a message on GetSpellTexture type function for buffs
    Man I've got curly braces all over the place. Guess I'll have something to do tomorrow during the patch.
    Posted in: Lua Code Discussion
  • 0

    posted a message on LF: nameplate "combat" shine texture
    Can you post a screenshot of what you're talking about? I'm not sure what you mean by combat shine.
    Posted in: Lua Code Discussion
  • 0

    posted a message on "Using" a spell with the keyboard
    I'm at the point where I'm learning about bindings and I came across CAMERAORSELECTORMOVE which fired my spell awaiting target selection.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Newbe Request for assistance
    I followed the wowwiki guide last week and got it to work, though I changed the xml to lua. Here would be a copy paste example.

    function FunctionCalledWhenOptionIsClicked()
    	print("clicked")
    end
    
    function MyDropDownMenu_OnLoad()
    	info	= {}
    	info.text	= "This is an option in the menu."
    	info.value	= "OptionVariable"
    	info.func	= FunctionCalledWhenOptionIsClicked
    	UIDropDownMenu_AddButton(info)
    end
    
    function MyDropDownMenuButton_OnClick() 
    	ToggleDropDownMenu(1, nil, MyDropDownMenu, MyDropDownMenuButton, 0, 0)
    end
    
    
    local b = CreateFrame("Button", "MyDropDownMenuButton", UIParent, "OptionsButtonTemplate")
    b:SetScript("OnClick",
    	function(self, button, down)
    		MyDropDownMenuButton_OnClick()
    	end)
    
    local f = CreateFrame("Frame", "MyDropDownMenu", UIParent, "UIDropDownMenuTemplate")
    f:SetID(1)
    UIDropDownMenu_Initialize(MyDropDownMenu, MyDropDownMenu_OnLoad, "MENU")
    
    b:SetPoint("CENTER")
    Posted in: Lua Code Discussion
  • 0

    posted a message on GetSpellTexture type function for buffs
    You could add a table to filter in my above example. This just outputs the icon to the chat frame but you could change it to update button textures as well.


    local buffs = {
    	["Divine Plea"] = true,
    	["Infusion of Light"] = true,
    }
    
    local f = CreateFrame("Frame", nil, UIParent)
    f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    f:SetScript("OnEvent",
    	function(self, event, ...)
    		if event == "COMBAT_LOG_EVENT_UNFILTERED" and arg2 == "SPELL_AURA_REMOVED" and arg7 == UnitName("player") and buffs[arg10] then
    			local icon = ({GetSpellInfo(arg9)})[3]
    			print("|T"..icon..":16|t "..arg10.." has faded.")
    		end
    	end)
    Posted in: Lua Code Discussion
  • 0

    posted a message on GetSpellTexture type function for buffs
    You could do something like this:

    local f = CreateFrame("Frame", nil, UIParent)
    f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    f:SetScript("OnEvent",
    	function(self, event, ...)
    		if event == "COMBAT_LOG_EVENT_UNFILTERED" and arg2 == "SPELL_AURA_REMOVED" and arg4 == UnitName("player") then
    			local icon = ({GetSpellInfo(arg9)})[3]
    			print("|T"..icon..":16|t "..arg10.." has faded.")
    		end
    	end)
    Posted in: Lua Code Discussion
  • 0

    posted a message on Most Popular Resolution
    What's the most common game resolution people use? I noticed when switching resolutions my UI elements shift around slightly (mostly the text). What should I do my testing in to appeal to most users?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Battleground Raid Target Icons
    Not sure if something like this exists, but in battlegrounds you can't put raid target icons on enemy players (not sure why). As I've been playing around with nameplates I've found that I can add icons all day long to nameplates on my own screen. If everyone had the same addon, you could tell their addon to display the icon on the same nameplate as yours.

    This would allow you to mark someone and everyone around would focus fire on a single player, taking them out faster. Of course you could just say "everyone kill hardtopronouncename", but people are more likely to attack whatever has a skull over its head.

    Also, not sure if this would be trying to circumvent something that Blizzard doesn't want you to do.
    Posted in: Addon Ideas
  • 0

    posted a message on "Using" a spell with the keyboard
    I'm not sure for the ground targeting effects, but for single target abilities, I was able to cast a cursor spell awaiting target selection by pressing a /target macro.

    For example, I made a macro "/target player" and set it as keyboard 1. I cleared my target, clicked on Lifebloom (waiting target selection at this point) and pressed 1 and it cast on myself.

    Not sure if this is what you're asking.
    Posted in: Lua Code Discussion
  • 0

    posted a message on 2d portrait
    I noticed this too. I ended up putting a temporary portrait (Interface\\CharacterFrame\\TemporaryPortrait-Male-Human) behind it in case it doesn't load. Not that this solves the issue.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Help with Button Text and Tooltips
    Quote from Phanx
    Also, in your code, OnEnter, OnLeave, b1, b2, and b3 should be local variables, not globals.


    Quote from Xchg
    If I put my buttons in a table like you said, then I think I can get rid of the global lookups.


    These two statements are more profound than I thought. When I do

    b1 = CreateFrame("Button", "Button1")

    I am creating two global variables that point to the same object. If in game I type

    /run b1 = CreateFrame("Button", "Button1")
    /run print(b1)
    /run print(Button1)

    I get the same thing.


    By saying

    local b1 = CreateFrame("Button", "Button1")

    I'm eliminating one of the globals but Button1 still exists as global.


    So in my icon browser, I'm preserving the global namespace by saying

    local b = CreateFrame("Button")

    but then I'm polluting it again when I get to "Icon"..i. At least I'm only creating 25 global variables instead of 50!


    But by pushing my buttons into tables, I can refer to them by a local table name instead of needing to have unique global names. This changes the way I need to think about the naming convention I use for my all of my frames, not just buttons. Where I've been doing

    local f = CreateFrame("Frame", "Frame1", UIParent)
    local f = CreateFrame("Frame", "Frame2", Frame1)
    Frame1:DoStuff()
    Frame2:DoStuff()

    I need to instead do

    local frames = {}

    frames.Frame1 = CreateFrame("Frame", nil, UIParent)
    frames.Frame2 = CreateFrame("Frame", nil, frames.Frame1)
    frames.Frame1:DoStuff()
    frames.Frame2:DoStuff()
    Posted in: Lua Code Discussion
  • 0

    posted a message on Help with Button Text and Tooltips
    Quote from Xchg
    /run IconBrowser("Interface\\Icons\\Spell_Shaman_SpiritLink")


    SpiritLink doesn't contain a space, I don't know why it's adding one.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Help with Button Text and Tooltips
    So this works! Thanks.
    /run s="Interface\\Icons\\INV_Misc_QuestionMark" print( string.match(s, "\\([%w_]*)$") )

    Are there any other characters that could appear in an icon name that I'm not including? Would it just be alphanumeric and underscores?


    So I guess I'm ready to post my code then. First I created my scrollframe by following one of the tutorials.

    		local f = CreateFrame("Frame", "IconBrowserFrame", UIParent)
    		f:SetFrameStrata("BACKGROUND")
    		f:SetWidth(184)
    		f:SetHeight(168)
    		f:SetPoint("CENTER")
    		f:SetBackdrop({bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", edgeFile="Interface\\Tooltips\\UI-Tooltip-Border", tile=true, tileSize=16, edgeSize=16, insets={left=4,right=4,top=4,bottom=4}})
    		table.insert(UISpecialFrames,"IconBrowserFrame")
    
    		local sf = CreateFrame("ScrollFrame", "IconBrowserScrollFrame", f)
    		sf:SetPoint("TOPLEFT")
    		sf:SetPoint("BOTTOMRIGHT")
    		sf:EnableMouseWheel(true)
    		sf:SetScript("OnMouseWheel", OnMouseWheel)
    		local sb = CreateFrame("Slider", "IconBrowserScrollbar", sf, "UIPanelScrollBarTemplate")
    		sb:SetPoint("TOPLEFT", sf, "TOPRIGHT", -20, -20)
    		sb:SetPoint("BOTTOMLEFT", sf, "BOTTOMRIGHT", -20, 20)
    		sb:SetMinMaxValues(1, GetNumMacroIcons())
    		sb:SetValueStep(1)
    		sb:SetWidth(16)
    		sb:SetScript("OnValueChanged", OnValueChanged)
    		local bg = sb:CreateTexture(nil, "BACKGROUND")
    		bg:SetAllPoints(sb)
    		bg:SetTexture(0, 0, 0, 0.4)



    Then I made my buttons, and stack them nice and neat like in a grid formation. Clicking the icon prints out the texture path the user selected. Later I'll change this to point to my config menu.

    		for i=1,25 do
    			local b = CreateFrame("Button", "Icon"..i, IconBrowserScrollFrame)
    			b:SetWidth(32)
    			b:SetHeight(32)
    			local t = b:CreateTexture(nil,"OVERLAY")
    			t:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark")
    			t:SetAllPoints()
    			b.texture = t
    			b:SetScript("OnEnter", OnEnter)
    			b:SetScript("OnLeave", OnLeave)
    			b:SetScript("OnClick", function(self, button, down) print(self.texture:GetTexture()) IconBrowserFrame:Hide() end)
    			if i==1 then
    				b:SetPoint("TOPLEFT","IconBrowserScrollFrame","TOPLEFT",4,-4)
    			elseif i>=2 and i<=5 then
    				b:SetPoint("TOPLEFT","Icon"..tostring(i-1),"TOPRIGHT")
    			elseif i>=6 then
    				b:SetPoint("TOPLEFT","Icon"..tostring(i-5),"BOTTOMLEFT")
    			end
    		end



    I've got my tooltips from before. I think I found the standard naming convention I was looking for. It seems tooltipText is the yellow 'header' of the tooltip and tooltipRequirement is the white 'body' of the tooltip. I know I can call them whatever I want, but I'd rather follow some sort of structure.

    	local function OnEnter(self, motion)
    		if GetMouseFocus().tooltipRequirement then
    			GameTooltip:SetOwner(IconBrowserScrollFrame, "ANCHOR_TOP")
    			GameTooltip:SetText("Icon "..tostring(GetMouseFocus().tooltipText))
    			GameTooltip:AddLine(tostring(GetMouseFocus().tooltipRequirement), 1, 1, 1)
    			GameTooltip:Show()
    		end
    	end
    
    	local function OnLeave(self, motion)
    		GameTooltip:Hide()
    	end



    Now the fun parts. I've got the mouse wheel scrolling in increments of five so I scroll by row and not one icon at a time.

    	local function OnMouseWheel(self, delta)
    		IconBrowserScrollbar:SetValue(IconBrowserScrollbar:GetValue() + delta * -5)
    	end



    I'm also snapping the scroll value to the first one in the row, so things don't get shifted around. If I put my buttons in a table like you said, then I think I can get rid of the global lookups. Nice, I'll work on that next. (I'm also refreshing the tooltip with the on enter on leave)

    	local function OnValueChanged(self, value)
    		value = floor((value-1)/5)*5+1
    		for i=1,25 do
    			local iconTexture = GetMacroIconInfo(value+i-1)
    			_G["Icon"..i].texture:SetTexture(iconTexture)
    			_G["Icon"..i].tooltipText = value+i-1
    			_G["Icon"..i].tooltipRequirement = string.match(iconTexture, "\\([%w_]*)$")
    		end
    		OnLeave()
    		OnEnter()
    	end



    I call my function with IconBrowser(iconTexture), where iconTexture is an existing texture path you want to jump to in the browser. If none is provided, it starts at the beginning. I loop through the icons until I get a match, then I know the index to start at.

    	local iconIndex = 1
    	if iconTexture then
    		for i=1,GetNumMacroIcons() do
    			if GetMacroIconInfo(i) == iconTexture then
    				iconIndex = i
    			end
    		end
    	end
    	IconBrowserScrollbar:SetValue(iconIndex)
    	IconBrowserFrame:Show()



    Here's the full code http://paste.wowace.com/2511/. So in game at the chat prompt you can type

    /run IconBrowser()

    or even

    /run IconBrowser("Interface\\Icons\\Spell_Shaman_SpiritLink")
    Posted in: Lua Code Discussion
  • 0

    posted a message on Help with Button Text and Tooltips
    Quote from Xchg
    object


    I think I mean variable.


    I seem to be using this thread more as a sounding board for my own thought process; I'm not sure if that's good or bad. Anyway, I'm on scrollframes now and am taking a hiatus from the other UI objects while I play with this one a bit.

    I've decided to try and create an icon browser, something like on the macros frame. I'm looping my buttons like in my previous example (still looking for feedback on that one), and am able to populate all the buttons with the textures as returned by GetMacroIconInfo(). My question now is on pattern matching. I want to extract the icon name from the texture path and set it as the tooltip. So I'm playing around with it in game at the chat frame:

    /run s="Interface\\Icons\\INV_Misc_QuestionMark" print( string.match(s, "\\([%w%p]*)$") )

    Maybe my confusion is because I don't know what's included in the punctuation class. Will it include my underscores? Is backslash punctuation or an escape character?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Help with Button Text and Tooltips
    How do I create like 20 buttons? At first I thought I could use inheritsFrame from one of my other buttons, but I learned this is only available if the template was created in XML.

    I then thought I could create a function to do most of the work for me:

    local function CreateButton(buttonName, parentFrame)
    	local b = CreateFrame("Button", buttonName, parentFrame)
    
    	local t = b:CreateTexture()
    	t:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark")
    	t:SetWidth(16)
    	t:SetHeight(16)
    	t:SetPoint("LEFT")
    	b.texture = t
    
    	local fs = b:CreateFontString(buttonName.."Text", nil, "GameFontNormal")
    	fs:SetText("New Button")
    	fs:SetPoint("CENTER")
    	b:SetFontString(fs)
    	b.text = fs
    
    	b.tooltipText = "Blank tooltip"
    	b:SetScript("OnClick", function(self, button, down) print(self:GetName()) end)
    	return b
    end
    
    
    b1 = CreateButton("Button1", Frame1)
    b2 = CreateButton("Button2", Frame1)
    ...
    b19 = CreateButton("Button19", Frame1)
    b20 = CreateButton("Button20", Frame1)



    But what about looping through them:

    for i=1,20 do
    	_G["b"..i] = CreateButton("Button"..i, Frame1)
    	_G["b"..i]:SetPoint("TOP",0,-24*i)
    	_G["b"..i]:SetText("Button"..i)
    end


    or

    for i=1,20 do
    	local b = CreateButton("Button"..i, Frame1)
    	b:SetPoint("TOP",0,-24*i)
    	b:SetText("Button"..i)
    end


    or

    for i=1,20 do
    	CreateButton("Button"..i, Frame1)
    	_G["Button"..i]:SetPoint("TOP",0,-24*i)
    	_G["Button"..i]:SetText("Button"..i)
    end



    Do I need to assign the buttons to something or just disregard the object all together and henceforth refer to my buttons by their names?
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.