Skip to content

Commit 49464db

Browse files
authored
feat: ✨ added is_mod_loaded() (#251)
1 parent ca40996 commit 49464db

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

addons/mod_loader/api/mod.gd

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,22 @@ static func get_mod_data_from_mod_id(mod_id: String) -> ModData:
110110
return ModLoaderStore.mod_data[mod_id]
111111

112112

113+
# Returns true if the mod with the given mod_id was successfully loaded.
114+
static func is_mod_loaded(mod_id: String) -> bool:
115+
if ModLoaderStore.is_initializing:
116+
ModLoaderLog.warning(
117+
"The ModLoader is not fully initialized. " +
118+
"Calling \"is_mod_loaded()\" in \"_init()\" may result in an unexpected return value as mods are still loading.",
119+
LOG_NAME
120+
)
121+
122+
# If the mod is not present in the mod_data dictionary or the mod is flagged as not loadable.
123+
if not ModLoaderStore.mod_data.has(mod_id) or not ModLoaderStore.mod_data[mod_id].is_loadable:
124+
return false
125+
126+
return true
127+
128+
113129
static func append_node_in_scene(modified_scene: Node, node_name: String = "", node_parent = null, instance_path: String = "", is_visible: bool = true) -> void:
114130
var new_node: Node
115131
if not instance_path == "":

0 commit comments

Comments
 (0)