lua - How to increment a variable in a table and access it? -
lua - How to increment a variable in a table and access it? -
i have table defined like:
local counter = { deleted = 0, moved = 0, sumoffilesize = 0, }
i have tried next increment or values, doesn't work:
increment: counter.deleted = counter.deleted + 1
get: counter.deleted
how can modify or read these values?
if youre using in functions need declare whitout local, , meaby can declare in top of file
counter={deleted = 0, moved = 0, sumoffilesize = 0}
for access in functions want.
the problem place because seek in console , here result, problem isnt lua
counter = { deleted = 0, moved = 0, sumoffilesize = 0, } print(counter) table: 0x7fb1e2e005d0 counter.deleted = counter.deleted + 1 print(counter.deleted) 1 counter.deleted = counter.deleted + 1 print(counter.deleted) 2 counter.deleted = counter.deleted + 1 print(counter.deleted) 3
lua
Comments
Post a Comment