diff --git a/main/main.cpp b/main/main.cpp index 752a248b2fc..149b3b775e7 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1327,6 +1327,29 @@ bool Main::start() { //autoload List props; Globals::get_singleton()->get_property_list(&props); + + //first pass, add the constants so they exist before any script is loaded + for(List::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;iadd_global_constant(name,Variant()); + } + } + + } + + //second pass, load into global constants for(List::Element *E=props.front();E;E=E->next()) { String s = E->get().name; @@ -1374,7 +1397,6 @@ bool Main::start() { } } - } } diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index cf8f762a86b..a69f99314a1 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -534,6 +534,7 @@ public: virtual void auto_indent_code(String& p_code,int p_from_line,int p_to_line) const; virtual void add_global_constant(const StringName& p_variable,const Variant& p_value); + /* DEBUGGER FUNCTIONS */ virtual String debug_get_error() const;