Thread Tools Display Modes
11-17-10, 03:02 PM   #1
Felankor
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: May 2007
Posts: 26
Question Get Index of a Macro Icon Texture

Hi,

I am fed up of having to change the Macro Icon index's every time there is an update. Is there a way to either get the Index of an icon texture or create a macro using an icon texture instead of an index?

Example
Code:
local numIcons = GetNumMacroIcons();
local iconTexture = GetMacroIconInfo(1);
DEFAULT_CHAT_FRAME:AddMessage(iconTexture);

Result
Displays Interface\Icons\INV_Misc_QuestionMark in the default chat frame.
Is there a way to do that in reverse? E.g.

Code:
local numIcons = GetNumMacroIcons();
local iconIndex= GetMacroIconIndex("Interface\Icons\INV_Misc_QuestionMark");
DEFAULT_CHAT_FRAME:AddMessage(iconIndex);

Result
Displays 1 in the default chat frame.
OR

Code:
CreateMacro("MyMacro", "Interface\Icons\INV_Misc_QuestionMark", "Macro Text/Code", nil, 1);
If I can find the index for a texture or create a macro using the texture instead of the index, I wouldn't have to keep counting the macro icons to find out what the index has increased by.

Hope this makes sense.

Thanks in advance,

Felankor
  Reply With Quote
11-17-10, 03:04 PM   #2
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
Code:
local numIcons = GetNumMacroIcons();
local index
for i=1, numIcons do
  if GetMacroIconInfo(i) == "Interface\Icons\INV_Misc_QuestionMark" then
    index = i
    break
  end
end

print(index)
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote
11-17-10, 03:13 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Code:
function GetMacroIndexByTexture(texture)
	for i = 1, GetNumMacroIcons() do
		if GetMacroIconInfo(i) == texture then
			return i
		end
	end
end
  Reply With Quote
11-17-10, 03:15 PM   #4
Felankor
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: May 2007
Posts: 26
Thumbs up

lmao now I feel stupid. Don't know why I didn't think of that. Thank you

Felankor
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Get Index of a Macro Icon Texture


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