Now get_global in Engine won't print an error if the global isn't exists, instead it will just return null.

This commit is contained in:
Relintai 2022-08-25 11:25:12 +02:00
parent a1865fd1af
commit f9de65e101

View File

@ -92,9 +92,13 @@ void Engine::add_global(const String &p_name, const Variant &p_global) {
_globals.set(p_name, p_global);
}
Variant Engine::get_global(const String &p_name) {
ERR_FAIL_COND_V(!_globals.has(p_name), Variant());
Variant *vptr = _globals.getptr(p_name);
return _globals[p_name];
if (!vptr) {
return Variant();
}
return *vptr;
}
void Engine::remove_global(const String &p_name) {
ERR_FAIL_COND(!_globals.has(p_name));