Saturday, 15 May 2010

lua - How to add a string automatically at the end of a table row -



lua - How to add a string automatically at the end of a table row -

i have table made of several rows , variable number of columns in each rows.

if want add together info in new row, do

table[#table+1] = {['d1'] = data, ['d2'] = data, ... }

now i'd if want add together line 1 (for example):

table[1] = {['d' .. #columns+1] = data}

except not work , can't find solution.

my problem right when code adds info existing row, overwrites existing data, not want.

for illustration result 1 line of table:

-- table: {4} { ["d3"]=154.04, },

instead of having 'd1', 'd2' , 'd3' have 'd3'.

the code

table[1] = {['d' .. #columns] = data}

replaces value @ table[1] table on right.

try instead:

table[1]['d' .. #columns] = data

lua lua-table

No comments:

Post a Comment