Hello everyone.
I am a total lua beginner but want to create a addon to see the level/tier of ingredients.
Because I am a noob in it I stole pretty much everything in my code from various genius modders
But now I am stuck.
I try to do the same as ingeniousclown with his brilliant research assistant but instead of showing a texture in the column I want to show the user a label with the tier of the item.
(The Version with a texture works more or less (of course my database is far from complete))
Lua Code:
local function CreateTierControl(parent)
local control = WINDOW_MANAGER:CreateControl(parent:GetName() .. "Tier", parent, CT_Label) -- if this is set to CT_Texture with more or less the same values it will show the texture and will be colorizable
control:SetDimensions(30, 30)
control:SetAnchor(CENTER, parent, CENTER, 100)
control:SetText("Error")
control:SetFont("ZoGameFont")
control:SetHidden(true) -- even if this is set to false it will not show anything
return control
end
local function AddTierToSlot(control)
local bagId = control.dataEntry.data.bagId
local slotIndex = control.dataEntry.data.slotIndex
local tierControl = control:GetNamedChild("Tier")
if(not tierControl) then
tierControl = CreateTierControl(control)
table.insert(controlsToWatch, tierControl)
end
local itemType = GetItemType(bagId, slotIndex)
tierControl:SetHidden(true)
if(itemType == ITEMTYPE_INGREDIENT) then
local itemName = GetItemName(bagId, slotIndex)
itemName = string.gsub(itemName,"s^p","") -- because of the annoying plural names
local tier = getTier(language, itemName) -- will give back a number
local color = getColor(language, itemName) -- will give back a color (black if item is not yet listed)
if(tier ~= nil) then
if(color == "green") then
tierControl:SetColor(0, 1, 0, 1)
elseif(color == "blue") then
tierControl:SetColor(0, 0, 1, 1)
elseif(color == "violet") then
tierControl:SetColor(1, 0, 1, 1)
elseif(color == "gold") then
tierControl:SetColor(1, 1, 0, 1)
else
tierControl:SetColor(0, 0, 0, 0)
end
tierControl:SetHidden(false)
end
end
end
Like I said this is a bit stolen so it is for my personal use only until I have permission from ingeniousclown to edit his code and upload it. - But that will come later first I need to understand what I am doing wrong.
Sorry for my english I hope you can help me