Skip to content

Commit

Permalink
Add @GDScript.type_exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Geequlim committed Jun 18, 2016
1 parent 57c67fb commit 7124599
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions modules/gdscript/gd_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const char *GDFunctions::get_func_name(Function p_func) {
"funcref",
"convert",
"typeof",
"type_exists",
"str",
"print",
"printt",
Expand Down Expand Up @@ -531,6 +532,12 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
VALIDATE_ARG_COUNT(1);
r_ret = p_args[0]->get_type();

} break;
case TYPE_EXISTS: {

VALIDATE_ARG_COUNT(1);
r_ret = ObjectTypeDB::type_exists(*p_args[0]);

} break;
case TEXT_STR: {

Expand Down Expand Up @@ -1126,6 +1133,7 @@ bool GDFunctions::is_deterministic(Function p_func) {
case LOGIC_NEAREST_PO2:
case TYPE_CONVERT:
case TYPE_OF:
case TYPE_EXISTS:
case TEXT_STR:
case COLOR8:
// enable for debug only, otherwise not desirable - case GEN_RANGE:
Expand Down Expand Up @@ -1388,6 +1396,13 @@ MethodInfo GDFunctions::get_info(Function p_func) {
mi.return_val.type=Variant::INT;
return mi;

} break;
case TYPE_EXISTS: {

MethodInfo mi("type_exists",PropertyInfo(Variant::STRING,"type"));
mi.return_val.type=Variant::BOOL;
return mi;

} break;
case TEXT_STR: {

Expand Down
1 change: 1 addition & 0 deletions modules/gdscript/gd_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class GDFunctions {
FUNC_FUNCREF,
TYPE_CONVERT,
TYPE_OF,
TYPE_EXISTS,
TEXT_STR,
TEXT_PRINT,
TEXT_PRINT_TABBED,
Expand Down

0 comments on commit 7124599

Please sign in to comment.