Skip to content

Commit 8e26af5

Browse files
committed
fix: 🐛 set current_config in ModData._load_config() (#523)
* fix: 🐛 set `current_config` in `ModData._load_config()` Fixed an issue where `current_config` was null because it wasn't set in `ModData._load_config()`. closes #466 * fix: 🐛 added method to check if user profiles are initialized * fix: 🐛 `current_config` = default if no user profile
1 parent 91f751a commit 8e26af5

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

addons/mod_loader/api/profile.gd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ static func get_all_as_array() -> Array:
187187
return user_profiles
188188

189189

190+
# Returns true if the Mod User Profiles are initialized.
191+
# On the first execution of the game, user profiles might not yet be created.
192+
# Use this method to check if everything is ready to interact with the ModLoaderUserProfile API.
193+
static func is_initialized() -> bool:
194+
return _ModLoaderFile.file_exists(FILE_PATH_USER_PROFILES)
195+
196+
190197
# Internal profile functions
191198
# =============================================================================
192199

addons/mod_loader/mod_loader.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ func _init() -> void:
6060
return
6161

6262
# Load user profiles into ModLoaderStore
63-
var _success_user_profile_load := ModLoaderUserProfile._load()
63+
if ModLoaderUserProfile.is_initialized():
64+
var _success_user_profile_load := ModLoaderUserProfile._load()
6465

6566
_load_mods()
6667

addons/mod_loader/resources/mod_data.gd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ func load_configs() -> void:
8888
_load_config(config_file_path)
8989

9090
# Set the current_config based on the user profile
91-
current_config = ModLoaderConfig.get_current_config(dir_name)
91+
if ModLoaderUserProfile.is_initialized():
92+
current_config = ModLoaderConfig.get_current_config(dir_name)
93+
else:
94+
current_config = ModLoaderConfig.get_config(dir_name, ModLoaderConfig.DEFAULT_CONFIG_NAME)
9295

9396

9497
# Create a new ModConfig instance for each Config JSON and add it to the configs dictionary.

0 commit comments

Comments
 (0)