diff options
| author | Juan Linietsky | 2016-01-13 08:27:14 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2016-01-13 08:27:14 -0300 |
| commit | 5fca2bd4bc66b246eb331adef01e11858ba80e3c (patch) | |
| tree | 365e0387e88d174c2948cd518ad506fd74518dde /main/main.cpp | |
| parent | c4cee22510bc8222e66ef2a7fd5d158371ac07e0 (diff) | |
| download | godot-5fca2bd4bc66b246eb331adef01e11858ba80e3c.tar.gz godot-5fca2bd4bc66b246eb331adef01e11858ba80e3c.tar.zst godot-5fca2bd4bc66b246eb331adef01e11858ba80e3c.zip | |
Diffstat (limited to 'main/main.cpp')
| -rw-r--r-- | main/main.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/main/main.cpp b/main/main.cpp index 752a248b2..149b3b775 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1327,6 +1327,29 @@ bool Main::start() { //autoload List<PropertyInfo> props; Globals::get_singleton()->get_property_list(&props); + + //first pass, add the constants so they exist before any script is loaded + for(List<PropertyInfo>::Element *E=props.front();E;E=E->next()) { + + String s = E->get().name; + if (!s.begins_with("autoload/")) + 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; + } + + if (global_var) { + for(int i=0;i<ScriptServer::get_language_count();i++) { + ScriptServer::get_language(i)->add_global_constant(name,Variant()); + } + } + + } + + //second pass, load into global constants for(List<PropertyInfo>::Element *E=props.front();E;E=E->next()) { String s = E->get().name; @@ -1374,7 +1397,6 @@ bool Main::start() { } } - } } |
