Skip to content

feat: ✨ added is_mod_loaded() #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions addons/mod_loader/api/mod.gd
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ static func get_mod_data_from_mod_id(mod_id: String) -> ModData:
return ModLoaderStore.mod_data[mod_id]


# Returns true if the mod with the given mod_id was successfully loaded.
static func is_mod_loaded(mod_id: String) -> bool:
if ModLoaderStore.is_initializing:
ModLoaderLog.warning(
"The ModLoader is not fully initialized. " +
"Calling \"is_mod_loaded()\" in \"_init()\" may result in an unexpected return value as mods are still loading.",
LOG_NAME
)

# If the mod is not present in the mod_data dictionary or the mod is flagged as not loadable.
if not ModLoaderStore.mod_data.has(mod_id) or not ModLoaderStore.mod_data[mod_id].is_loadable:
return false

return true


static func append_node_in_scene(modified_scene: Node, node_name: String = "", node_parent = null, instance_path: String = "", is_visible: bool = true) -> void:
var new_node: Node
if not instance_path == "":
Expand Down