diff options
author | George Marques <george@gmarqu.es> | 2018-05-01 11:06:23 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2018-05-01 11:44:08 -0300 |
commit | decf178033d4176b0955b8efa8a081f7bccd7ed1 (patch) | |
tree | b69138dfb949dde62a8adfc206cdd9f9d478e4d9 /modules/gdscript/gdscript_function.cpp | |
parent | 613a8bee415381a8564d34092b479e1f159e8e60 (diff) | |
download | redot-engine-decf178033d4176b0955b8efa8a081f7bccd7ed1.tar.gz |
Enable autoload in editor
- Tool scripts will be executed and can be accessed by plugins.
- Other script languages can implement add/remove_named_global_constant
to make use of this functionality.
Diffstat (limited to 'modules/gdscript/gdscript_function.cpp')
-rw-r--r-- | modules/gdscript/gdscript_function.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index d32ce25d3c..62394c8c43 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -108,6 +108,21 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta #endif return &GDScriptLanguage::get_singleton()->get_global_array()[address]; } break; +#ifdef TOOLS_ENABLED + case ADDR_TYPE_NAMED_GLOBAL: { +#ifdef DEBUG_ENABLED + ERR_FAIL_INDEX_V(address, _named_globals_count, NULL); +#endif + StringName id = _named_globals_ptr[address]; + + if (GDScriptLanguage::get_singleton()->get_named_globals_map().has(id)) { + return (Variant *)&GDScriptLanguage::get_singleton()->get_named_globals_map()[id]; + } else { + r_error = "Autoload singleton '" + String(id) + "' has been removed."; + return NULL; + } + } break; +#endif case ADDR_TYPE_NIL: { return &nil; } break; |