0 votes

So here I'm appending some data to 'tohit' in a loop. The function 'game.getstatssnapshot()' from a singleton.
But the snapshot returns don't seem to be written properly somehow?

            var snapshot = [] + game._get_stats_snapshot()
            print(snapshot)
            to_hit.append([game.objects[i.x][i.y],0,map_compute_pass,Vector2(i.x,i.y),snapshot]) 
            game.objects[i.x][i.y] = 0

for i in to_hit: print(i)

snapshot:
[50, 0, [74, 1, 1, 1, 1], [0, 0, 0, 0, 0]]
[50, 0, [73, 1, 1, 1, 1], [0, 0, 0, 0, 0]]
[50, 0, [72, 1, 1, 1, 1], [0, 0, 0, 0, 0]]
to_hit:
[1, 0, 0, (4, 3), [50, 0, [72, 1, 1, 1, 1], [0, 0, 0, 0, 0]]]
[1, 0, 0, (4, 5), [50, 0, [72, 1, 1, 1, 1], [0, 0, 0, 0, 0]]]
[1, 0, 0, (4, 4), [50, 0, [72, 1, 1, 1, 1], [0, 0, 0, 0, 0]]]

As you can see the sequence there should be 74>73>72 but just ends up as 72>72>72

Any help much appreciated <3

in Engine by (12 points)

Can you put your singleton script on here? We need more info. to help, put all functions you referenced in your code snippet on your post please. Thanks.

What Moldor2 said. Also, you claim to add data in a loop, but there is no loop (other than the one for printing the data). And if there was a loop, the loop variable (i?) should probably also be added as index for the snapshot (snapshot[i]).

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.