SavedVariables are global, TableOfItems is not really a unique enough name for a global. Same goes for frame names, "myTest" is not really a unique enough name for a global. You might be binding to some other "myTest" button.
Lua Code:
local function addItemToTable(itemID)
print("add item function fired", itemID)
for k, v in pairs(TableOfItems) do
if v == itemID then
print("Item all ready listed")
else
table.insert(TableOfItems, 1, itemID)
print("Item added to list")
end
end
end
This is possibly going to cause problems as you're inserting a new entry for each time there is no match. If you start with an empty table, there will also be no k, v to test against so no new entries will be added... ever.
Lua Code:
local function addItemToTable(itemID)
if not TableOfItems then -- you could move this here if you don't want to create an event frame
TableOfItems = {}
end
print("add item function fired", itemID)
local found
for k, v in pairs(TableOfItems) do
if v == itemID then
print("Item all ready listed")
found = true
break
end
end
if not found then
table.insert(TableOfItems, 1, itemID)
print("Item added to list")
end
end