summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeequlim <geequlim@gmail.com>2016-06-18 15:07:51 +0800
committerGeequlim <geequlim@gmail.com>2016-06-18 15:07:51 +0800
commit71245995a4813d49449ac055f77cf60c896b483d (patch)
tree33fb513c6345fcb63eafaf9520d714b10f480e05
parent57c67fb0f7515564ae739e828d2f4320785d789c (diff)
Add @GDScript.type_exists
-rw-r--r--modules/gdscript/gd_functions.cpp15
-rw-r--r--modules/gdscript/gd_functions.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index 90528614b3..ec66841662 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -87,6 +87,7 @@ const char *GDFunctions::get_func_name(Function p_func) {
"funcref",
"convert",
"typeof",
+ "type_exists",
"str",
"print",
"printt",
@@ -532,6 +533,12 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
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: {
String str;
@@ -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:
@@ -1389,6 +1397,13 @@ MethodInfo GDFunctions::get_info(Function p_func) {
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: {
MethodInfo mi("str",PropertyInfo(Variant::NIL,"what"),PropertyInfo(Variant::NIL,"..."));
diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h
index 8c88472567..c78956fe20 100644
--- a/modules/gdscript/gd_functions.h
+++ b/modules/gdscript/gd_functions.h
@@ -81,6 +81,7 @@ public:
FUNC_FUNCREF,
TYPE_CONVERT,
TYPE_OF,
+ TYPE_EXISTS,
TEXT_STR,
TEXT_PRINT,
TEXT_PRINT_TABBED,