View Single Post
10/05/14, 04:02 PM   #7
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Baertram, do you mean something like this:

Since you said you wanted Marked to be a table I'm guessing items can have more than one mark?
So you probably want something like this:


NEW Function: to check and see if an item is already marked, don't want to mark an item twice:
Lua Code:
  1. -- Function used to see if the item has already been marked (dont want duplicate marks in your table) --
  2. local function FCOIsItemMarked(control, mark)
  3.     local bIsMarked = false
  4.    
  5.     if ((control.dataEntry.data.FCO == nil) or (control.dataEntry.data.FCO.ItemSaver == nil)
  6.     or (control.dataEntry.data.FCO.ItemSaver.Marked == nil)) then return bIsMarked end
  7.    
  8.     for k,v in pairs(control.dataEntry.data.FCO.ItemSaver.Marked) do
  9.         if v == mark then
  10.             bIsMarked = true
  11.         end
  12.     end
  13.     return bIsMarked
  14. end

Altered Function: FCOItemSaver_AddInfoToData(control)
  1. checks to see if the control.data.dataEntry exists
  2. checks to see if your myItemInstanceId exists
  3. loops through your marked Indices from 1 to gFCONumFilterIcons
  4. checks to see if the myItemInstanceId exists in your markedItems[markedIndex] table
  5. checks to see if the item control.dataEntry.data.FCO.ItemSaver.Marked table already has the mark in it to avoid duplicates
  6. checks to see of the tables exist, if not it creates them
  7. last, inserts the mark into the table
Lua Code:
  1. local function FCOItemSaver_AddInfoToData(control)
  2.     if ((control ~= nil) and (control.dataEntry ~= nil) and (control.dataEntry.data ~= nil)) then
  3.     local myItemInstanceId = MyGetItemInstanceId(control)
  4.         if (myItemInstanceId ~= nil) then
  5.             debugMessage("[FCOItemSaver_AddInfoToData] ItemIstanceId:" .. tostring(myItemInstanceId))
  6.             --Check if the current item is marked with any of the marker icons
  7.             for markedIndex=1, gFCONumFilterIcons, 1 do
  8.                 if markedItems[markedIndex][myItemInstanceId] and (not FCOIsItemMarked(control, "Mark"..markedIndex))then
  9.                     --if the table doesn't exist create it --
  10.                     if control.dataEntry.data.FCO == nil then
  11.                         control.dataEntry.data.FCO = {}
  12.                         control.dataEntry.data.FCO.ItemSaver = {}
  13.                         control.dataEntry.data.FCO.ItemSaver.Marked = {}
  14.                     end
  15.                            
  16.                     table.insert(control.dataEntry.data.FCO.ItemSaver.Marked, "Mark"..markedIndex)
  17.                 end
  18.             end
  19.         end
  20.     end
  21. end

Last edited by circonian : 10/05/14 at 04:59 PM.
  Reply With Quote