Add seed/get_inst function for GDScript
seed -> Math::seed get_inst -> ObjectDB::get_instance
This commit is contained in:
parent
cbad0440ab
commit
97f34a1dd6
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue