How to make loading screen wait until further conditions than just the scene loading

Godot Version

Godot 4.5stable

Question

I have a loading screen alongside a scaling map generation however the scene will load properly before the generation finishes, what would be the easiest way to make it so the loading screen waits until the map is completely generated first?

I did not make the loading screen myself, I followed a tutorial I had found as I do not quite understand the ins and outs of threaded loading yet.

Map Generation:

func placeGrass(areaX,areaY):
	for i in areaY+1:
		for k in areaX+1:
			var grassBlade = grass.instantiate()
			grassBlade.position.x = (0.5 * -areaX/2) + (k * 0.5)
			grassBlade.position.z = (0.5 * -areaY/2) + (i * 0.5)
			grassBlade.rotation.y = deg_to_rad(randi())
			add_child(grassBlade)
			global.grassTotal += 1
			k += 1
		i += 1
		if i % 5 == 0: await get_tree().process_frame

Loading Screen:

extends Node

signal progress_changed(progress)
signal load_finished()

var loading_screen:PackedScene = preload("uid://bfc4ubf4m18ua")
var loaded_resource:PackedScene
var scene_path: String
var progress:Array = []
var use_sub_threads:bool = true

func _ready() -> void:
	set_process(false)

func load_scene(_scene_path: String) -> void:
	scene_path = _scene_path
	
	var new_load_screen = loading_screen.instantiate()
	add_child(new_load_screen)
	progress_changed.connect(new_load_screen._on_progress_changed)
	load_finished.connect(new_load_screen._on_load_finished)
	
	await new_load_screen.loading_screen_ready
	
	start_load()

func start_load() -> void:
	var state = ResourceLoader.load_threaded_request(scene_path, "", use_sub_threads)
	if state == OK:
		set_process(true)

func _process(_delta) -> void:
	var load_status = ResourceLoader.load_threaded_get_status(scene_path, progress)
	progress_changed.emit(progress[0])
	match load_status:
		ResourceLoader.THREAD_LOAD_INVALID_RESOURCE, ResourceLoader.THREAD_LOAD_FAILED:
			set_process(false)
		ResourceLoader.THREAD_LOAD_LOADED:
			loaded_resource = ResourceLoader.load_threaded_get(scene_path)
			get_tree().change_scene_to_packed(loaded_resource)
			load_finished.emit()

Is placeGrass() in the loaded scene? How do you call it?

placeGrass() is in the loaded scene and called immediately upon ready.

How long does it take to execute?

at smaller sizes it executes in time for the loading screen but once the size is large enough due to waiting for frames to process to prevent freezing and crashing it can take upwards of a minute

You should use multi mesh instance for grass. Having a scene for each blade is not very economical.

each piece of grass is a clump of 4 relatively low-detail blades and each grass scene contains scripts and areas required for proper function of the main game scene, i’m not too knowledgeable on game development as a whole to deduce any better way to do it

Instantiate and add the loading screen again at the start of scene’s _ready(). Delete it after placeGrass() returns. Disable any player interaction in meantime or just skip the await part as that will block the execution of any processing code until placeGrass() finishes.