diff options
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gd_functions.cpp | 36 | ||||
-rw-r--r-- | modules/gdscript/gd_functions.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_script.cpp | 2 |
3 files changed, 38 insertions, 2 deletions
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index f37b2f645a..d4b8639c9b 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -71,6 +71,7 @@ const char *GDFunctions::get_func_name(Function p_func) { "randi", "randf", "rand_range", + "seed", "rand_seed", "deg2rad", "rad2deg", @@ -97,6 +98,7 @@ const char *GDFunctions::get_func_name(Function p_func) { "dict2inst", "hash", "print_stack", + "get_inst", }; return _names[p_func]; @@ -328,6 +330,13 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va VALIDATE_ARG_NUM(1); r_ret=Math::random(*p_args[0],*p_args[1]); } break; + case MATH_SEED: { + VALIDATE_ARG_COUNT(1); + VALIDATE_ARG_NUM(0); + uint32_t seed=*p_args[0]; + Math::seed(seed); + r_ret=Variant(); + } break; case MATH_RANDSEED: { VALIDATE_ARG_COUNT(1); VALIDATE_ARG_NUM(0); @@ -575,7 +584,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va } //str+="\n"; - OS::get_singleton()->print("%s\n",str.utf8().get_data()); + OS::get_singleton()->print("%s",str.utf8().get_data()); r_ret=Variant(); } break; @@ -895,6 +904,20 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va }; } break; + case GET_INST: { + + VALIDATE_ARG_COUNT(1); + if (p_args[0]->get_type()!=Variant::INT && p_args[0]->get_type()!=Variant::REAL) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=0; + r_ret=Variant(); + break; + } + + uint32_t id=*p_args[0]; + r_ret=ObjectDB::get_instance(id); + + } break; case FUNC_MAX: { ERR_FAIL_V(); @@ -1130,6 +1153,11 @@ MethodInfo GDFunctions::get_info(Function p_func) { mi.return_val.type=Variant::REAL; return mi; } break; + case MATH_SEED: { + MethodInfo mi("seed",PropertyInfo(Variant::REAL,"seed")); + mi.return_val.type=Variant::NIL; + return mi; + } break; case MATH_RANDSEED: { MethodInfo mi("rand_seed",PropertyInfo(Variant::REAL,"seed")); mi.return_val.type=Variant::ARRAY; @@ -1288,6 +1316,12 @@ MethodInfo GDFunctions::get_info(Function p_func) { return mi; } break; + case GET_INST: { + MethodInfo mi("get_info",PropertyInfo(Variant::INT,"instance_id")); + mi.return_val.type=Variant::OBJECT; + return mi; + } break; + case FUNC_MAX: { ERR_FAIL_V(MethodInfo()); diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h index 05ff6a2e73..4fbfe99228 100644 --- a/modules/gdscript/gd_functions.h +++ b/modules/gdscript/gd_functions.h @@ -67,6 +67,7 @@ public: MATH_RAND, MATH_RANDF, MATH_RANDOM, + MATH_SEED, MATH_RANDSEED, MATH_DEG2RAD, MATH_RAD2DEG, @@ -93,6 +94,7 @@ public: DICT2INST, HASH, PRINT_STACK, + GET_INST, FUNC_MAX }; diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 06c746c4fb..f13b51c008 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -1689,7 +1689,7 @@ bool GDScript::_update_exports() { } - if (c->extends_used && String(c->extends_file)!="") { + if (c->extends_used && String(c->extends_file)!="" && String(c->extends_file) != get_path()) { String path = c->extends_file; if (path.is_rel_path()) { |