diff --git a/addons/mod_loader/api/profile.gd b/addons/mod_loader/api/profile.gd index abac4287..8283f6de 100644 --- a/addons/mod_loader/api/profile.gd +++ b/addons/mod_loader/api/profile.gd @@ -187,6 +187,13 @@ static func get_all_as_array() -> Array: return user_profiles +# Returns true if the Mod User Profiles are initialized. +# On the first execution of the game, user profiles might not yet be created. +# Use this method to check if everything is ready to interact with the ModLoaderUserProfile API. +static func is_initialized() -> bool: + return _ModLoaderFile.file_exists(FILE_PATH_USER_PROFILES) + + # Internal profile functions # ============================================================================= diff --git a/addons/mod_loader/mod_loader.gd b/addons/mod_loader/mod_loader.gd index 29af8c5c..1f668564 100644 --- a/addons/mod_loader/mod_loader.gd +++ b/addons/mod_loader/mod_loader.gd @@ -60,7 +60,8 @@ func _init() -> void: return # Load user profiles into ModLoaderStore - var _success_user_profile_load := ModLoaderUserProfile._load() + if ModLoaderUserProfile.is_initialized(): + var _success_user_profile_load := ModLoaderUserProfile._load() _load_mods() diff --git a/addons/mod_loader/resources/mod_data.gd b/addons/mod_loader/resources/mod_data.gd index c7640e09..5c252f45 100644 --- a/addons/mod_loader/resources/mod_data.gd +++ b/addons/mod_loader/resources/mod_data.gd @@ -88,7 +88,10 @@ func load_configs() -> void: _load_config(config_file_path) # Set the current_config based on the user profile - current_config = ModLoaderConfig.get_current_config(dir_name) + if ModLoaderUserProfile.is_initialized(): + current_config = ModLoaderConfig.get_current_config(dir_name) + else: + current_config = ModLoaderConfig.get_config(dir_name, ModLoaderConfig.DEFAULT_CONFIG_NAME) # Create a new ModConfig instance for each Config JSON and add it to the configs dictionary.