how can i manipulated my var from other scene?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By potatobanana

how can i manipulated 3 in PlayerGlobalStat.player_ditc_3 ?, i want it same num with my var slot_id = 1

reason: i need to make many save data. it become so long . this 3 out 10.

	var newsave = File.new()
	var error = newsave.open(save_path + str(slot_id_from_slection) +".json" ,File.WRITE)# math save_ file with slot_id
	if error == OK:
		newsave.store_line(to_json(get_tree().get_root().get_node(custom_room_path).temp_ditc))
		newsave.close()
		if slot_id_from_slection == 1:
			print(str(slot_id_from_slection))
			get_tree().get_root().get_node(slection_slot_path + "player_slot"+ str(slot_id_from_slection)).pressed = false
			get_tree().get_root().get_node(delete_path).disabled = true
			PlayerGlobalStat.player_ditc_1 = get_tree().get_root().get_node(custom_room_path).temp_ditc
	
		elif slot_id_from_slection == 2:
			get_tree().get_root().get_node(slection_slot_path + "player_slot"+ str(slot_id_from_slection)).pressed = false
			get_tree().get_root().get_node(delete_path).disabled = true
			PlayerGlobalStat.player_ditc_2 = get_tree().get_root().get_node(custom_room_path).temp_ditc
	
		elif slot_id_from_slection == 3:
			get_tree().get_root().get_node(slection_slot_path + "player_slot"+ str(slot_id_from_slection)).pressed = false
			get_tree().get_root().get_node(delete_path).disabled = true
			PlayerGlobalStat.player_ditc_3 = get_tree().get_root().get_node(custom_room_path).temp_ditc

if i do like this

var dict_array = [print("nothing"),
PlayerGlobalStat.player_dict_1,
PlayerGlobalStat.player_dict_2,
PlayerGlobalStat.player_dict_3,
PlayerGlobalStat.player_dict_4,
PlayerGlobalStat.player_dict_5,
PlayerGlobalStat.player_dict_6,
PlayerGlobalStat.player_dict_7]

then do like this
dict_array[slot_id_from_slection] = get_tree().get_root().get_node(custom_room_path).temp_dict

this just my array that being replace

it work:

i just use match

match slot_id_from_slection:
	1: 
		PlayerGlobalStat.player_dict_1 = get_tree().get_root().get_node(custom_room_path).temp_dict
		print(PlayerGlobalStat.player_dict_1["biography"])
	2:
		PlayerGlobalStat.player_dict_2 = get_tree().get_root().get_node(custom_room_path).temp_dict
		print(PlayerGlobalStat.player_dict_2["biography"])
	3:
		PlayerGlobalStat.player_dict_3 = get_tree().get_root().get_node(custom_room_path).temp_dict
		print(PlayerGlobalStat.player_dict_3["biography"])
	4:
		PlayerGlobalStat.player_dict_4 = get_tree().get_root().get_node(custom_room_path).temp_dict
		print(PlayerGlobalStat.player_dict_4["biography"])
	5: 
		PlayerGlobalStat.player_dict_5 = get_tree().get_root().get_node(custom_room_path).temp_dict
		print(PlayerGlobalStat.player_dict_5["biography"])
	6: 
		PlayerGlobalStat.player_dict_6 = get_tree().get_root().get_node(custom_room_path).temp_dict
		print(PlayerGlobalStat.player_dict_6["biography"])
	7: 
		PlayerGlobalStat.player_dict_7 = get_tree().get_root().get_node(custom_room_path).temp_dict
		print(PlayerGlobalStat.player_dict_7["biography"])

potatobanana | 2021-03-01 13:07