Godot Version
4.1.2 stable Linux x86 64bit appimage
When trying to make a system to save a tilemap upon exiting the game, a dictionary meant to keep track of each tile returns it’s starting value despite a function being called to “update” said variable where the variable is changed only when it is looked at from that function and nothing else.
var tileset = {}
func update_tileset():
for xy in get_used_cells(0):
if xy not in tileset:
tileset[xy] = solve_for_xy(xy)
if tileset[xy][1]==0:
set_cell(0, xy, 0, Vector2i(clamp(tileset[xy][0][0]-1, 0, 2), tileset[xy][0][1]))
tileset[xy] = solve_for_xy(xy)
print(tileset[xy])
elif tileset[xy][1] < -50:
if round(randi()%clamp(500+tileset[xy][1], 1, 500)) == 0:
erase_cell(0, xy)
tileset.erase(xy)
tileset[xy][1] -= 1
return tileset
when calling the function and looking at the return or the tileset it will be {} or the starting value of the tileset varible. Is there a way to fix this?