I create a simple table like: aY = {128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128}
Conditions that should be met when I insert arpYnote = Value into the table:
** No duplicates, but I still need the key of said value.
** If the table is full with other values than 128, do nothing.
for i,v in ipairs(aY) do
if v == 128 then arpH = i break end
end
for i,v in ipairs(aY) do
if v == arpYnote arpF = i break end
end
if arpH <= 16 and arpF == nil then
table.remove(aY,arpH)
table.insert(aY,arpH,arpYnote)
elseif arpH<= 16 and arpF <= 16 then
table.remove(aY,arpF)
table.insert(aY,arpF,arpYnote)
elseif arpH == nil and arpF <=16 then
-- (should do something else)
elseif arpH == nil and arpF == nil then
--(should do nothing)
end
I can see the 128 values get replaced by the arpYnote values and I get no duplicates. But when i reach the end of the table it keeps replacing the last value, which is not what I want. It never reaches the last elseif statement. What gives?