getting a loading's progress

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

Hello ! I’d like to get the progress of the preloading of my ingame scene to update my loading bar. But this line seems to be the problem :

var progress = float(thread.get_stage()) / thread.get_stage_count()

Here is the code :

onready var thread = Thread.new()
onready var current_scene =  get_node("/root/titlescreen")

func load_nextscene():
 	thread.start(self,"prep_scene", ResourceLoader.load_interactive("res://scenes/ingame.tscn"))


func prep_scene(interactive_ldr):
   	while (true):
   		var err = interactive_ldr.poll();
		if(err == ERR_FILE_EOF): 
			call_deferred("_on_load_level_done");
			return interactive_ldr.get_resource();
			
		elif(err == OK):
			update_progress()

func update_progress():
	var progress = float(thread.get_stage()) / thread.get_stage_count()    
	get_node("/root/titlescreen/ProgressBar").value = progress;

I tried changing “thread” with “thread.interactive_ldr” and “interactive_ldr” but none worked :confused: thanks !