View Single Post
04/08/14, 05:40 AM   #1
Tyx
 
Tyx's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 23
Need help with ingredients mod

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:
  1. local function CreateTierControl(parent)
  2.     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
  3.     control:SetDimensions(30, 30)
  4.     control:SetAnchor(CENTER, parent, CENTER, 100)
  5.     control:SetText("Error")
  6.     control:SetFont("ZoGameFont")
  7.     control:SetHidden(true) -- even if this is set to false it will not show anything
  8.    
  9.     return control
  10. end
  11.  
  12. local function AddTierToSlot(control)
  13.     local bagId = control.dataEntry.data.bagId
  14.     local slotIndex = control.dataEntry.data.slotIndex
  15.    
  16.     local tierControl = control:GetNamedChild("Tier")
  17.     if(not tierControl) then
  18.         tierControl = CreateTierControl(control)
  19.         table.insert(controlsToWatch, tierControl)
  20.     end
  21.  
  22.     local itemType = GetItemType(bagId, slotIndex)
  23.     tierControl:SetHidden(true)
  24.     if(itemType == ITEMTYPE_INGREDIENT) then
  25.         local itemName = GetItemName(bagId, slotIndex)
  26.         itemName = string.gsub(itemName,"s^p","") -- because of the annoying plural names
  27.         local tier = getTier(language, itemName) -- will give back a number
  28.         local color = getColor(language, itemName) -- will give back a color (black if item is not yet listed)
  29.         if(tier ~= nil) then
  30.             if(color == "green") then
  31.                 tierControl:SetColor(0, 1, 0, 1)
  32.             elseif(color == "blue") then
  33.                 tierControl:SetColor(0, 0, 1, 1)
  34.             elseif(color == "violet") then
  35.                 tierControl:SetColor(1, 0, 1, 1)
  36.             elseif(color == "gold") then
  37.                 tierControl:SetColor(1, 1, 0, 1)
  38.             else
  39.                 tierControl:SetColor(0, 0, 0, 0)
  40.             end        
  41.             tierControl:SetHidden(false)   
  42.         end
  43.     end
  44. 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
  Reply With Quote