What you are doing does not make sense because second parameter to valueExists
is a timestamp
, which becomes "value" in valueExists
, but in this function will be "e" type item. If I rename according to the way you call it and change some names so it is consistent, you would have something like:
local function valueExists(tbl, timestamp)
for k,e in ipairs(tbl) do
if timestamp ~= e.timestamp then
table.insert(existingMTable.History, e)
print("value" .. timestamp)
print("e.timestamp" .. e.timestamp)
#print(existingMTable.History.timestamp) -- WRONG because you inserted an e two lines above here
end
end
return false
end
Now you can see the above does not make sense:
- you are mixing "e" tables with timestamp values.
- you are calling with the timestamp of last e added by setupTable, so valueExists will find the last item in table to have the searched timestamp
Take a look at the above: what are you actually try to do in that valueExists function?