Skip to content

Commit 00b8159

Browse files
committed
feat: ✨ added get_dict_from_dict()
used in `ModManifest` to get `config_schema`
1 parent 7c70fab commit 00b8159

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

addons/mod_loader/internal/mod_loader_utils.gd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ static func get_array_from_dict(dict: Dictionary, key: String) -> Array:
3434
return dict[key]
3535

3636

37+
# Returns an empty Dictionary if the key does not exist or is not type of Dictionary
38+
static func get_dict_from_dict(dict: Dictionary, key: String) -> Dictionary:
39+
if not dict.has(key):
40+
return {}
41+
42+
if not dict[key] is Dictionary:
43+
return {}
44+
45+
return dict[key]
46+
47+
3748
# Works like [method Dictionary.has_all],
3849
# but allows for more specific errors if a field is missing
3950
static func dict_has_fields(dict: Dictionary, required_fields: Array) -> bool:

0 commit comments

Comments
 (0)