summaryrefslogtreecommitdiff
path: root/modules/gdscript/gdscript.cpp
diff options
context:
space:
mode:
authorocean (they/them) <anvilfolk@gmail.com>2022-12-19 23:09:32 -0500
committerocean (they/them) <anvilfolk@gmail.com>2022-12-20 19:01:28 -0500
commitfb418685a00a235d472c8f80c8e17d6091444fa5 (patch)
tree17e85c61b9ba2c9eee2200f235aa07429de676fe /modules/gdscript/gdscript.cpp
parent2a04b18d37de6c6e621db5a9dfd1cd0da5ccb015 (diff)
Unify GDScriptAnalyzer in-editor and runtime autoload checks
Diffstat (limited to 'modules/gdscript/gdscript.cpp')
-rw-r--r--modules/gdscript/gdscript.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 57a29cc81e..1fe1561559 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -1966,6 +1966,16 @@ void GDScriptLanguage::add_named_global_constant(const StringName &p_name, const
named_globals[p_name] = p_value;
}
+Variant GDScriptLanguage::get_any_global_constant(const StringName &p_name) {
+ if (named_globals.has(p_name)) {
+ return named_globals[p_name];
+ }
+ if (globals.has(p_name)) {
+ return _global_array[globals[p_name]];
+ }
+ ERR_FAIL_V_MSG(Variant(), vformat("Could not find any global constant with name: %s.", p_name));
+}
+
void GDScriptLanguage::remove_named_global_constant(const StringName &p_name) {
ERR_FAIL_COND(!named_globals.has(p_name));
named_globals.erase(p_name);