diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-04-07 20:19:07 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-04-07 20:19:07 -0300 |
commit | 8619cb64baf8a267056fec83f90f29aa2446317a (patch) | |
tree | ecf47dac5ae9d603fbbfe22405d57866bd31d8de /modules/gdscript | |
parent | b989498004ad8cb16625ecdfea428b1c8664fee3 (diff) | |
parent | 97f34a1dd6b472318df80d801f80f8d5eecd9e99 (diff) |
Merge pull request #1567 from sanikoyes/Pr-GDScript-seed-get-inst
Pr-GDScript-seed-get-inst
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gd_functions.cpp | 34 | ||||
-rw-r--r-- | modules/gdscript/gd_functions.h | 2 |
2 files changed, 36 insertions, 0 deletions
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index ce2cb14643..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); @@ -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 }; |