diff options
author | reduz <reduzio@gmail.com> | 2015-12-28 15:59:20 -0300 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2015-12-28 15:59:20 -0300 |
commit | e0d21d2158e8d03ee3139392284915c19ee4619b (patch) | |
tree | ca2614960a86a2c2626365f8afec6ad1291aea95 /main | |
parent | 5d47e42eb69fcc0d1f502f9b5e72e064cb22d34e (diff) |
Ability to set autoloads as singleton global variables
Diffstat (limited to 'main')
-rw-r--r-- | main/main.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/main/main.cpp b/main/main.cpp index 66391ffa7e..8127bba3e9 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1330,6 +1330,12 @@ bool Main::start() { continue; String name = s.get_slicec('/',1); String path = Globals::get_singleton()->get(s); + bool global_var=false; + if (path.begins_with("*")) { + global_var=true; + path=path.substr(1,path.length()-1); + } + RES res = ResourceLoader::load(path); ERR_EXPLAIN("Can't autoload: "+path); ERR_CONTINUE(res.is_null()); @@ -1355,7 +1361,16 @@ bool Main::start() { ERR_EXPLAIN("Path in autoload not a node or script: "+path); ERR_CONTINUE(!n); n->set_name(name); + sml->get_root()->add_child(n); + + if (global_var) { + for(int i=0;i<ScriptServer::get_language_count();i++) { + ScriptServer::get_language(i)->add_global_constant(name,n); + } + } + + } } |