Skip to content

Commit a3ff6c4

Browse files
authored
✔ added checks for override.cfg setup (#110)
* ✔ added checks for override.cfg setup * 🧹 removed logging when no autoloads are set up If there is no autoloads there will be no mod_loader.gd
1 parent 52104d5 commit a3ff6c4

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

addons/mod_loader/mod_loader.gd

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,25 +169,32 @@ func _init() -> void:
169169
# Ensure ModLoader is the first autoload
170170
func _check_first_autoload() -> void:
171171
var autoload_array = ModLoaderUtils.get_autoload_array()
172-
var is_mod_loader_first = autoload_array.find("ModLoader") == 0
172+
var mod_loader_index = autoload_array.find("ModLoader")
173+
var is_mod_loader_first = mod_loader_index == 0
173174

174-
var base_msg = "ModLoader needs to be the first autoload to work correctly, "
175-
var help_msg = ""
175+
var override_cfg_path = ModLoaderUtils.get_override_path()
176+
var is_override_cfg_setup = ModLoaderUtils.file_exists(override_cfg_path)
176177

177178
# Log the autoloads order. Might seem superflous but could help when providing support
178179
ModLoaderUtils.log_debug_json_print("Autoload order", autoload_array, LOG_NAME)
179180

181+
# If the override file exists we assume the ModLoader was setup with the --setup-create-override-cfg cli arg
182+
# In that case the ModLoader will be the last entry in the autoload array
183+
if is_override_cfg_setup:
184+
ModLoaderUtils.log_info("override.cfg setup detected, ModLoader will be the last autoload loaded.", LOG_NAME)
185+
return
186+
187+
var base_msg = "ModLoader needs to be the first autoload to work correctly, "
188+
var help_msg = ""
189+
180190
if OS.has_feature("editor"):
181-
help_msg = "To configure your autoloads, to go Project > Project Settings > Autoload, and add ModLoader as the first item. For more info, see the 'Godot Project Setup' page on the ModLoader GitHub wiki."
191+
help_msg = "To configure your autoloads, go to Project > Project Settings > Autoload, and add ModLoader as the first item. For more info, see the 'Godot Project Setup' page on the ModLoader GitHub wiki."
182192
else:
183193
help_msg = "If you're seeing this error, something must have gone wrong in the setup process."
184194

185195
if not is_mod_loader_first:
186196
ModLoaderUtils.log_fatal(str(base_msg, 'but the first autoload is currently: "%s". ' % autoload_array[0], help_msg), LOG_NAME)
187197

188-
if autoload_array.size() == 0:
189-
ModLoaderUtils.log_fatal(str(base_msg, "but no autoloads are currently set up. ", help_msg), LOG_NAME)
190-
191198

192199
# Loop over "res://mods" and add any mod zips to the unpacked virtual directory
193200
# (UNPACKED_DIR)

addons/mod_loader/mod_loader_setup.gd

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,18 @@ var is_setup_create_override_cfg : bool = modloaderutils.is_running_with_command
4141
func _init() -> void:
4242
modloaderutils.log_debug("ModLoader setup initialized", LOG_NAME)
4343

44+
var mod_loader_index: int = modloaderutils.get_autoload_index("ModLoader")
45+
4446
# Avoid doubling the setup work
4547
# Checks if the ModLoader Node is in the root of the scene tree
4648
# and if the IS_LOADER_SETUP_APPLIED project setting is there
47-
if modloaderutils.get_autoload_index("ModLoader") == 0:
49+
if mod_loader_index == 0:
50+
modded_start()
51+
return
52+
53+
# Check if --setup-create-override-cfg is passed,
54+
# in that case the ModLoader just has to be somewhere in the autoloads.
55+
if is_setup_create_override_cfg and mod_loader_index != -1:
4856
modded_start()
4957
return
5058

0 commit comments

Comments
 (0)