This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
9TYNINE's profile picture

Index Expected got nil

Started by 9TYNINE, 06 December 2018 - 12:16 PM
9TYNINE #1
Posted 06 December 2018 - 01:16 PM
hi im making a "tracker" for a pokemon randomizer and im getting an error
this is my code and it cant be because the Pokenum Variable is not declared as it is working fine for loops and such
however if i remove the [1] and the [2] before my "=" then it works
but this wont work for me as i need it nested that way.
Is there sime kind of nesting limit


    for i=1,table.getn(Pokemon[Pokenum][2])+1 do
         if Pokemon[Pokenum][2][i] == MoveType then
             Pokemon[Pokenum][2][i] = MoveEffect
         elseif i==table.getn(Pokemon[Pokenum][2])+1 then
             Pokemon[Pokenum][2][i][1] = MoveType --ERROR LINE
             Pokemon[Pokenum][2][i][2] = MoveEffect
         end
    end
9TYNINE #2
Posted 06 December 2018 - 02:01 PM
never mind i fixed it by making an empty table before the error line :D/>