Multiply loads bug

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Serenade
:warning: Old Version Published before Godot 3 was released.

I have made load func, where it finds files(TSCN) and then loads them when you press the button, but it loads them on scene every time i press load button, so how can i make it recognise that it already loaded them, so that it doesnt load them on every tie you press the button? Heres my code…

var dir =
var folder = ("res://SAVES_folder")

if == OK:
	var FILES = dir.get_next() 
	while FILES != "":
		if not dir.current_is_dir() :
			var file_path = folder + "/" + FILES 
			var path = load(file_path) #shortcut for the filepath combo
			var obj = path.instance() #instance the shortcut to load
		FILES = dir.get_next()

I tried to make a counter, when there have been scenes loaded, it adds +1 and then if loaded scenes >1, do not load and such, but didnt work…

:bust_in_silhouette: Reply From: Anutrix

I am not sure but this seems to be logical problem(unless I am mistaken). You can try following (untested python derived )simple code instead of add_child(obj):

var filesAdded      #Array to store filepath of added files
if current not in fileadded:

Take a look at my file copy finder written in python for reference.
Also I guess you to take a look at Python book like this if you haven’t yet.