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:
-- Function used to see if the item has already been marked (dont want duplicate marks in your table) --
local function FCOIsItemMarked(control, mark)
local bIsMarked = false
if ((control.dataEntry.data.FCO == nil) or (control.dataEntry.data.FCO.ItemSaver == nil)
or (control.dataEntry.data.FCO.ItemSaver.Marked == nil)) then return bIsMarked end
for k,v in pairs(control.dataEntry.data.FCO.ItemSaver.Marked) do
if v == mark then
bIsMarked = true
end
end
return bIsMarked
end
Altered Function: FCOItemSaver_AddInfoToData(control)- checks to see if the control.data.dataEntry exists
- checks to see if your myItemInstanceId exists
- loops through your marked Indices from 1 to gFCONumFilterIcons
- checks to see if the myItemInstanceId exists in your markedItems[markedIndex] table
- checks to see if the item control.dataEntry.data.FCO.ItemSaver.Marked table already has the mark in it to avoid duplicates
- checks to see of the tables exist, if not it creates them
- last, inserts the mark into the table
Lua Code:
local function FCOItemSaver_AddInfoToData(control)
if ((control ~= nil) and (control.dataEntry ~= nil) and (control.dataEntry.data ~= nil)) then
local myItemInstanceId = MyGetItemInstanceId(control)
if (myItemInstanceId ~= nil) then
debugMessage("[FCOItemSaver_AddInfoToData] ItemIstanceId:" .. tostring(myItemInstanceId))
--Check if the current item is marked with any of the marker icons
for markedIndex=1, gFCONumFilterIcons, 1 do
if markedItems[markedIndex][myItemInstanceId] and (not FCOIsItemMarked(control, "Mark"..markedIndex))then
--if the table doesn't exist create it --
if control.dataEntry.data.FCO == nil then
control.dataEntry.data.FCO = {}
control.dataEntry.data.FCO.ItemSaver = {}
control.dataEntry.data.FCO.ItemSaver.Marked = {}
end
table.insert(control.dataEntry.data.FCO.ItemSaver.Marked, "Mark"..markedIndex)
end
end
end
end
end