diff --git a/demos/2d/space_shooter/game_state.gd b/demos/2d/space_shooter/game_state.gd index 26ef086f14c..f66d0fa8fa7 100644 --- a/demos/2d/space_shooter/game_state.gd +++ b/demos/2d/space_shooter/game_state.gd @@ -8,12 +8,12 @@ var max_points = 0 func _ready(): var f = File.new() #load high score + if (f.open("user://highscore",File.READ)==OK): max_points=f.get_var() - func game_over(): if (points>max_points): max_points=points diff --git a/demos/2d/space_shooter/rail.gd b/demos/2d/space_shooter/rail.gd index 803a09fe846..22ebd026708 100644 --- a/demos/2d/space_shooter/rail.gd +++ b/demos/2d/space_shooter/rail.gd @@ -14,7 +14,6 @@ var offset=0 func _process(delta): - offset+=delta*SPEED set_pos(Vector2(offset,0)) diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index c374f509c08..7cb9882f3ac 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -29,6 +29,7 @@ #include "gd_script.h" #include "gd_compiler.h" #include "globals.h" +#include "os/file_access.h" void GDScriptLanguage::get_comment_delimiters(List *p_delimiters) const { @@ -238,26 +239,26 @@ void GDScriptLanguage::debug_get_stack_level_members(int p_level,List *p if (_debug_parse_err_line>=0) return; - ERR_FAIL_INDEX(p_level,_debug_call_stack_pos); - int l = _debug_call_stack_pos - p_level -1; + ERR_FAIL_INDEX(p_level,_debug_call_stack_pos); + int l = _debug_call_stack_pos - p_level -1; - GDInstance *instance = _call_stack[l].instance; + GDInstance *instance = _call_stack[l].instance; - if (!instance) - return; + if (!instance) + return; - Ref script = instance->get_script(); - ERR_FAIL_COND( script.is_null() ); + Ref script = instance->get_script(); + ERR_FAIL_COND( script.is_null() ); - const Map& mi = script->debug_get_member_indices(); + const Map& mi = script->debug_get_member_indices(); - for(const Map::Element *E=mi.front();E;E=E->next()) { + for(const Map::Element *E=mi.front();E;E=E->next()) { - p_members->push_back(E->key()); - p_values->push_back( instance->debug_get_member_by_index(E->get().index)); - } + p_members->push_back(E->key()); + p_values->push_back( instance->debug_get_member_by_index(E->get().index)); + } } void GDScriptLanguage::debug_get_globals(List *p_locals, List *p_values, int p_max_subitems,int p_max_depth) { @@ -317,6 +318,7 @@ String GDScriptLanguage::make_function(const String& p_class,const String& p_nam struct GDCompletionIdentifier { StringName obj_type; + Ref script; Variant::Type type; Variant value; //im case there is a value, also return it }; @@ -446,7 +448,7 @@ static Ref _get_parent_class(GDCompletionContext& context) { base_class=base_class->subclasses[subclass]; } else { - print_line("Could not find subclass: "+subclass); + //print_line("Could not find subclass: "+subclass); return _get_type_from_class(context); //fail please } } @@ -631,7 +633,9 @@ static bool _guess_expression_type(GDCompletionContext& context,const GDParser:: //try calling the function if constant and all args are constant, should not crash.. Object *baseptr = base.value; - if (baseptr && mb->is_const() && pi.type==Variant::OBJECT) { + + if (mb->is_const() && pi.type==Variant::OBJECT) { + bool all_valid=true; Vector args; for(int i=2;iarguments.size();i++) { @@ -648,25 +652,88 @@ static bool _guess_expression_type(GDCompletionContext& context,const GDParser:: all_valid=false; } } - if (all_valid) { - Vector argptr; - for(int i=0;icall(baseptr,argptr.ptr(),argptr.size(),ce); + if (all_valid && String(id)=="get_node" && ObjectTypeDB::is_type(base.obj_type,"Node") && args.size()) { + + String arg1=args[0]; + if (arg1.begins_with("/root/")) { + String which = arg1.get_slice("/",2); + if (which!="") { + List props; + Globals::get_singleton()->get_property_list(&props); + //print_line("find singleton"); + + for(List::Element *E=props.front();E;E=E->next()) { + + String s = E->get().name; + if (!s.begins_with("autoload/")) + continue; + //print_line("found "+s); + String name = s.get_slice("/",1); + //print_line("name: "+name+", which: "+which); + if (name==which) { + String script = Globals::get_singleton()->get(s); + + if (!script.begins_with("res://")) { + script="res://"+script; + } + + if (!script.ends_with(".gd")) { + //not a script, try find the script anyway, + //may have some success + script=script.basename()+".gd"; + } + + if (FileAccess::exists(script)) { + + //print_line("is a script"); - if (ce.error==Variant::CallError::CALL_OK && ret.get_type()!=Variant::NIL) { + Ref