love2d - Lua get Max number -


i facing issue getting max number of attributes of array

-- getting maximum number of full grids inside row maxrow = math.max(checkerrow[1],checkerrow[2],checkerrow[3],checkerrow[4],checkerrow[5],                     checkerrow[6],checkerrow[7],checkerrow[8],checkerrow[9],checkerrow[10],                     checkerrow[11],checkerrow[12],checkerrow[13],checkerrow[14],checkerrow[15],                     checkerrow[16],checkerrow[17],checkerrow[18],checkerrow[19],checkerrow[20])  print("max row : "..maxrow) 

so prints out value inside maxrow, need can give me number of row, if checkerrow[6] max number, need maxrow equal 6.

i sorry if find question stupid, new lua.

this simple implementation. may wrap in function.

local mi, mv = 1, checkerrow[1] = 2, 20     if checkerrow[i] > mv         mi, mv = i, checkerrow[i]     end end 

Comments