So, obviously I am new to the WoW API and LUA in general, however I am a fairly experienced programmer in a few other languages. I am trying to write a mod for my guild, and I've made some headway with it.
What it does at the moment is register for loot events, and when I loot a corpse it creates buttons inside the mod frame that correspond to the loot on the mob. Later I want to add alot of click functionality, but for now I am trying and failing to get the buttons to work correctly.
I have them being correctly sized, and placed when they are instantiated. So, for example mob A has 2 drops, it makes 2 buttons inside the frame. I want those buttons to have the same icons and such as the loot that dropped.
Here is what the creation code looks like atm:
function createButton(buttonNumber, itemName, icon)
local newButton = CreateFrame("Button", itemName, CoreFrame, "ItemButtonTemplate")
positionButton(newButton, buttonNumber)
newButton:SetWidth(buttonSize)
newButton:SetHeight(buttonSize)
lootFrames[buttonNumber] = newButton
existingButtons = existingButtons + 1
end
|
And this is the calling function(s)
function lootOpened()
local counter = 1
numButtons = 0
numLoots = GetNumLootItems()
while (counter <= numLoots) do
local lootIcon, lootName, lootQuantity, rarity, locked = GetLootSlotInfo(counter);
createLootButton(counter, lootName, lootIcon)
counter = counter + 1
numButtons = numButtons + 1
end
end
function createLootButton(buttonNumber, itemName, icon)
-- Dynamically create a button for each loot item on the boss
if (buttonNumber <= existingButtons) then
--lootFrames[buttonNumber]:SetNormalTexture(icon)
lootFrames[buttonNumber]:Show()
elseif (buttonNumber > existingButtons) then
createButton(buttonNumber, itemName, icon)
end
end
|
I am using the ItemButtonTemplate for the buttons, and if you look in createLootButton I commented out
lootFrames[buttonNumber]:SetNormalTexture(icon)
|
In essence thats what I want to do, but obviously I can't set the NormalTexture to the icon of the drop, I need a way to access the texture that is used for the loot icon for each ItemButtonTemplate, I have no idea how.
Thanks for any help, sorry for the wall o' text for what is almost certianly a simple question, but I'm not sure what is relevant atm =)