Skip to content

Commit 9f14128

Browse files
improve comments
1 parent 1dcaa62 commit 9f14128

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

loader/mod_loader.gd

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ var mod_data = {}
8282
# Order for mods to be loaded in, set by `_get_load_order`
8383
var mod_load_order = []
8484

85-
# Override for the path mods are loaded from. Only gets set if the CLI arg
86-
# --mods-path is used. This can be tested in the editor via:
87-
# Project Settings > Display> Editor > Main Run Args
85+
# Override for the path mods are loaded from. Only set if the CLI arg is present.
86+
# Can be tested in the editor via: Project Settings > Display> Editor > Main Run Args
87+
# Default: "res://mods"
88+
# Set via: --mods-path
89+
# Example: --mods-path="C://path/mods"
8890
var os_mods_path_override = ""
8991

9092
# Any mods that are missing their dependancies are added to this
@@ -209,6 +211,8 @@ func mod_log(text:String, mod_name:String = "Unknown-Mod", pretty:bool = false)-
209211
log_file.close()
210212

211213

214+
# Loop over "res://mods" and add any mod zips to the unpacked virtual directory
215+
# (UNPACKED_DIR)
212216
func _load_mod_zips():
213217
# Path to the games mod folder
214218
var game_mod_folder_path = _get_mod_folder_dir()
@@ -247,12 +251,15 @@ func _load_mod_zips():
247251
var is_mod_loaded_success = ProjectSettings.load_resource_pack(mod_folder_global_path, false)
248252

249253
# Notifies developer of an issue with Godot, where using `load_resource_pack`
250-
# in the editor WIPES the entire res:// directory the first time you use it:
254+
# in the editor WIPES the entire virtual res:// directory the first time you
255+
# use it. This means that unpacked mods are no longer accessible, because they
256+
# no longer exist in the file system. So this warning basically says
257+
# "don't use ZIPs with unpacked mods!"
251258
# https://github.com/godotengine/godot/issues/19815
252259
# https://github.com/godotengine/godot/issues/16798
253260
if OS.has_feature("editor") && !has_shown_editor_warning:
254261
mod_log(str(
255-
"WARNING: Loading files with `load_resource_pack` will WIPE the entire virtual res:// directory. ",
262+
"WARNING: Loading ZIP files with `load_resource_pack` will WIPE the entire virtual res:// directory. ",
256263
"If you have any unpacked mods in ", UNPACKED_DIR, ", they will not be loaded. ",
257264
"Please unpack your mod ZIPs instead, and add them to ", UNPACKED_DIR), LOG_NAME)
258265
has_shown_editor_warning = true
@@ -271,6 +278,8 @@ func _load_mod_zips():
271278
dir.list_dir_end()
272279

273280

281+
# Loop over UNPACKED_DIR and triggers `_init_mod_data` for each mod directory,
282+
# which adds their data to mod_data.
274283
func _setup_mods():
275284
# Path to the unpacked mods folder
276285
var unpacked_mods_path = UNPACKED_DIR
@@ -484,7 +493,6 @@ func _init_mod(mod):
484493
add_child(mod_main_instance, true)
485494

486495

487-
488496
# Utils (Mod Loader)
489497
# =============================================================================
490498

@@ -510,7 +518,8 @@ func _get_cmd_line_arg(argument) -> String:
510518

511519
return ""
512520

513-
# Get the path to the (packed) mods folder, ie "res://mods" or the OS's equivalent
521+
# Get the path to a local folder. Primarily used to get the (packed) mods
522+
# folder, ie "res://mods" or the OS's equivalent, as well as the configs path
514523
func _get_mod_folder_dir():
515524
var game_install_directory = OS.get_executable_path().get_base_dir()
516525

0 commit comments

Comments
 (0)