Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Vododovoodvod |
Hi everyone,
I have data stored in 2D array, this would be example:
var stage_tiles_matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
I would like to access certain number and change it. Something like this:
stage_tiles_matrix [1][2] = 0
resulting in:
stage_tiles_matrix = [[1, 1, 1], [1, 1, 0], [1, 1, 1]]
However, when I type something like that I get error:
Expected ']'
How can I access certain value in such data structure and modify if?
When I ran your code, it worked. Did you have a syntax error somewhere?
exuin | 2020-09-15 21:59
I just ran it again in neutral environment and it indeed worked.
I will double check it when I get home. Maybe issue lies in stage_tiles_matrix
variable since I don’t declare it like here in example, but I read it from json file.
Eliminating stage_tiles_matrix [1][comment1-2] = 0
line as source of problem is still step forward.
I probably phrased data wrong, maybe engine treats it like string at the moment?
Anyway thanks!
I will post results when I get home and check variable more thoroughly.
Vododovoodvod | 2020-09-16 06:22