View Single Post
01/31/15, 06:31 PM   #2
katkat42
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 155
Your local variables are local to within that "if...end" statement. Once you pass that "end" your variables go out of scope. If you want them to be local to within the file, you need to declare them before the if statement:

Lua Code:
  1. local equipmentMarkerControlName, replaceEnd
  2. --Are we adding a tooltip to an equipment slot?
  3.         if pUpdateAllEquipmentTooltips then
  4.             --Get current controls name
  5.             equipmentMarkerControlName = markerControl:GetName()
  6.             --Get the offset for the ending digit(s)
  7.             replaceEnd = string.len(equipmentMarkerControlName) - locVars.gFCOMaxDigitsForIcons     -- locVars.gFCOMaxDigitsForIcons = 1
  8.             --Remove the ending number
  9.             equipmentMarkerControlName = string.sub(equipmentMarkerControlName, 1, replaceEnd)
  10.             d("name: " .. equipmentMarkerControlName)
  11.         end
  12.  
  13.         --Check if the item is marked with several icons
  14.         local markedIcons = {}
  15.         local bagId, slotIndex = MyGetItemDetails(markerControl:GetParent())
  16.         _, markedIcons = FCOIsMarked(GetItemInstanceId(bagId, slotIndex), -1)
  17.         for iconId, iconIsMarked in pairs(markedIcons) do
  18.             if iconIsMarked then
  19.                 markedCounter = markedCounter + 1
  20.                 if markedCounter > 1 then
  21.  
  22. --The variable will be NIL inside this FOR loop, but why?
  23.                 if iconId ~= markerId and pUpdateAllEquipmentTooltips then
  24.                     if equipmentMarkerControlName ~= "" then
  25.                     d("bla: " .. tostring(equipmentMarkerControlName))
  26.                     else
  27.                     d("blubb")
  28.                     end
  29.                 end
  30.             end
  31.         end
  Reply With Quote