Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | sephen |
I’ve got a global script to handle the game data.
in global.gd there are two variables with their getters and setters
var gameEntry = [] setget setGameEntry, getGameEntry
var gameEntries = [] setget setGameEntries, getGameEntries
Every time gameEntry is changed it will be appended to the gameEntries array.
But the strange thing is that when I add gameEntry to gameEntries and change gameEntry the gameEntry in gameEntries also changes like they are linked.
gameEntry = [0, 0, 0]
Add gameEntry to gameEntries
Global.setGameEntries(Global.getGameEntry())
func setGameEntries(entry):
gameEntries.append(entry)
gameEntries = [[0, 0, 0]]
change gameEntry to [1, 0, 1]
gameEntries = [[1, 0, 1]] // ??
expected behaviour:
gameEntries = [[0, 0, 0]]
How can i add the value of an array to another array without them being linked