From 513c0265c4760a7d04caa764a2f367d070e873e3 Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Mon, 3 Oct 2016 19:17:54 +0300 Subject: Add `String char(int ascii)` function to GDScript and Visual Script Just hope it doesn't crashes with that much pointer math... :smile: --- modules/gdscript/gd_functions.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'modules/gdscript/gd_functions.cpp') diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index a565e866d0..5d67f3cac0 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; @@ -1133,6 +1140,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: @@ -1402,6 +1410,13 @@ MethodInfo GDFunctions::get_info(Function p_func) { mi.return_val.type=Variant::BOOL; 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: { -- cgit v1.2.3 From e59820ac94b7c9706298d5559608937dfca332e5 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Tue, 4 Oct 2016 15:02:36 +0200 Subject: Add warning when (pre)loading paths with leading / (#4280 - #3106) --- modules/gdscript/gd_functions.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'modules/gdscript/gd_functions.cpp') diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index a565e866d0..0369e323bc 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -840,8 +840,13 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_ret=Variant(); + } else if(((String)(*p_args[0])).begins_with("/")) { + r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument=0; + r_ret=RTR("Paths cannot start with '/', absolute paths must start with \'res://\', \'user://\', or \'local://\'"); + } else { + r_ret=ResourceLoader::load(*p_args[0]); } - r_ret=ResourceLoader::load(*p_args[0]); } break; case INST2DICT: { -- cgit v1.2.3 From 2fb5a0030527ac04f1026d80bd8cf12ca3b3f38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sun, 9 Oct 2016 18:11:55 +0200 Subject: i18n: Fix string that broke msgmerge --- modules/gdscript/gd_functions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gdscript/gd_functions.cpp') diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index 0369e323bc..e82eb83773 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -843,7 +843,7 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va } else if(((String)(*p_args[0])).begins_with("/")) { r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; - r_ret=RTR("Paths cannot start with '/', absolute paths must start with \'res://\', \'user://\', or \'local://\'"); + r_ret=RTR("Paths cannot start with '/', absolute paths must start with 'res://', 'user://', or 'local://'"); } else { r_ret=ResourceLoader::load(*p_args[0]); } -- cgit v1.2.3 From 11349a786be1fd02647493cfeff9883898ffd73e Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Thu, 13 Oct 2016 11:28:38 +0200 Subject: Revert "Add warning when (pre)loading paths with leading / (#4280 - #3106)" Also closes: #6801 This reverts commit e59820ac94b7c9706298d5559608937dfca332e5. --- modules/gdscript/gd_functions.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'modules/gdscript/gd_functions.cpp') diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index e82eb83773..e224ce4718 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -840,10 +840,6 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_error.argument=0; r_ret=Variant(); - } else if(((String)(*p_args[0])).begins_with("/")) { - r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; - r_error.argument=0; - r_ret=RTR("Paths cannot start with '/', absolute paths must start with 'res://', 'user://', or 'local://'"); } else { r_ret=ResourceLoader::load(*p_args[0]); } -- cgit v1.2.3