Issue with table..

Home Forums General Programming Issue with table..

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #119139
    Tedjuh
    Participant
      • Topics: 9
      • Replies: 97
      • Total: 106
      • ★★

      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?

      #119141
      dnaldoog
      Participant
        • Topics: 4
        • Replies: 480
        • Total: 484
        • ★★

        post deleted

        • This reply was modified 3 years, 9 months ago by dnaldoog.
        • This reply was modified 3 years, 9 months ago by dnaldoog.
        • This reply was modified 3 years, 9 months ago by dnaldoog.
      Viewing 2 posts - 1 through 2 (of 2 total)
      • The forum ‘Programming’ is closed to new topics and replies.
      There is currently 0 users and 84 guests online
      No users are currently active
      Forum Statistics
      Threads: 2,495, Posts: 17,374, Members: 77,605
      Most users ever online was 12 on January 22, 2019 3:47 pm
      Ctrlr