summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2016-10-17 09:40:39 +0200
committerGitHub <noreply@github.com>2016-10-17 09:40:39 +0200
commit31e0e9536270e8973a9a42912517da7dd481fdb2 (patch)
tree8d3fea6934c4482f5632e331ebdb7e1eb02c0f79 /modules/gdscript
parent73cb001e4917cea0521a9417a9242f7c2cebcd38 (diff)
parent513c0265c4760a7d04caa764a2f367d070e873e3 (diff)
Merge pull request #6692 from bojidar-bg/add-char-to-gd-vs-script
Add `String char(int ascii)` function to GDScript and Visual Script
Diffstat (limited to 'modules/gdscript')
-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 e224ce4718..d3f7dcd35f 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -88,6 +88,7 @@ const char *GDFunctions::get_func_name(Function p_func) {
"convert",
"typeof",
"type_exists",
+ "char",
"str",
"print",
"printt",
@@ -538,6 +539,12 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
r_ret = ObjectTypeDB::type_exists(*p_args[0]);
} break;
+ case TEXT_CHAR: {
+ VALIDATE_ARG_COUNT(1);
+ VALIDATE_ARG_NUM(0);
+ CharType result[2] = {*p_args[0], 0};
+ r_ret=String(result);
+ } break;
case TEXT_STR: {
String str;
@@ -1134,6 +1141,7 @@ bool GDFunctions::is_deterministic(Function p_func) {
case TYPE_CONVERT:
case TYPE_OF:
case TYPE_EXISTS:
+ case TEXT_CHAR:
case TEXT_STR:
case COLOR8:
// enable for debug only, otherwise not desirable - case GEN_RANGE:
@@ -1404,6 +1412,13 @@ MethodInfo GDFunctions::get_info(Function p_func) {
return mi;
} break;
+ case TEXT_CHAR: {
+
+ MethodInfo mi("char",PropertyInfo(Variant::INT,"ascii"));
+ mi.return_val.type=Variant::STRING;
+ 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 c78956fe20..f444bb3b5b 100644
--- a/modules/gdscript/gd_functions.h
+++ b/modules/gdscript/gd_functions.h
@@ -82,6 +82,7 @@ public:
TYPE_CONVERT,
TYPE_OF,
TYPE_EXISTS,
+ TEXT_CHAR,
TEXT_STR,
TEXT_PRINT,
TEXT_PRINT_TABBED,