increment a string

hi,

Assuming i have this files in my directory :

paper1.png

paper2.png

paper3.png

i would make this :

local ext=".png" local papier={}    for i=1, 3 do         papier[i]="paper"..[i]..ext     end

how do you do ? my solution don’t works

“…[i]…” should be “…i…”

thanks it’s works

but in fact i’m searching to do a table like this :

but the problem is that “a” must be 6 when row egal 2 …

    local papier={}     local ext=".png"     for i = 1, 5 do         papier[i] = {};         for k = 1, 2 do             for a=1,10 do                 papier[i][k]="paper"..a..ext             end         end     end ---------------------------the result must be this     --    papier[1][1]="paper1.png"     --    papier[2][1]="paper2.png"     --    papier[3][1]="paper3.png"     --    papier[4][1]="paper4.png"     --    papier[5][1]="paper5.png"     --    papier[1][2]="paper6.png"     --    papier[2][2]="paper7.png"     --    papier[3][2]="paper8.png"     --    papier[4][2]="paper9.png"     --    papier[5][2]="paper10.png"

 

local count = 1 local papier={} local ext=".png" for i = 1, 5 do papier[i] = {}; for k = 1, 2 do papier[i][k]="paper" .. count .. ext count = count + 1 end end

or …

papier[i][k]="paper" .. (i-1)\*2+k .. ext

hi roaming,

thanks. the second solution is also very impressive due to his simplicity :o

“…[i]…” should be “…i…”

thanks it’s works

but in fact i’m searching to do a table like this :

but the problem is that “a” must be 6 when row egal 2 …

    local papier={}     local ext=".png"     for i = 1, 5 do         papier[i] = {};         for k = 1, 2 do             for a=1,10 do                 papier[i][k]="paper"..a..ext             end         end     end ---------------------------the result must be this     --    papier[1][1]="paper1.png"     --    papier[2][1]="paper2.png"     --    papier[3][1]="paper3.png"     --    papier[4][1]="paper4.png"     --    papier[5][1]="paper5.png"     --    papier[1][2]="paper6.png"     --    papier[2][2]="paper7.png"     --    papier[3][2]="paper8.png"     --    papier[4][2]="paper9.png"     --    papier[5][2]="paper10.png"

 

local count = 1 local papier={} local ext=".png" for i = 1, 5 do papier[i] = {}; for k = 1, 2 do papier[i][k]="paper" .. count .. ext count = count + 1 end end

or …

papier[i][k]="paper" .. (i-1)\*2+k .. ext

hi roaming,

thanks. the second solution is also very impressive due to his simplicity :o