View Single Post
10/05/14, 07:49 PM   #9
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
It could also be done without table.insert, we could assign a specific key refering to which mark it is.
Lua Code:
  1. control.dataEntry.data.FCO.ItemSaver.Marked = {[markedIndex] = true}

But then when you loop through it later to check marks you'de have to remember that there may be keys missing. For example if an item only had the 1st & 3rd mark:
Lua Code:
  1. Marked = {
  2. [1] = ...
  3. [3] = ...
  4. }
With the 2nd key missing. So you couldn't use
Lua Code:
  1. for k,v in pairs(control.dataEntry.data.FCO.ItemSaver.Marked) do
  2. ...
  3. end
Because the pairs loop would stop at the first nil key [2].

table.inert just makes it easier by ensuring the none of the keys for the table are missing so we dont have to worry about it later when searching through the table (but not the only way to do it).

It could also be done like this, if you only wanted to add 1 marker:
Lua Code:
  1. control.dataEntry.data.FCO.ItemSaver.Marked = "Mark"..markedIndex

or if you wanted to name them
Lua Code:
  1. control.dataEntry.data.FCO.ItemSaver.Marked = {["ReservedMark"] = true}
  Reply With Quote