diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2016-10-17 09:40:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-17 09:40:39 +0200 |
commit | 31e0e9536270e8973a9a42912517da7dd481fdb2 (patch) | |
tree | 8d3fea6934c4482f5632e331ebdb7e1eb02c0f79 /modules/visual_script | |
parent | 73cb001e4917cea0521a9417a9242f7c2cebcd38 (diff) | |
parent | 513c0265c4760a7d04caa764a2f367d070e873e3 (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/visual_script')
-rw-r--r-- | modules/visual_script/visual_script_builtin_funcs.cpp | 17 | ||||
-rw-r--r-- | modules/visual_script/visual_script_builtin_funcs.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 24a44d3506..2bfb6bc9ea 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -55,6 +55,7 @@ const char* VisualScriptBuiltinFunc::func_name[VisualScriptBuiltinFunc::FUNC_MAX "convert", "typeof", "type_exists", + "char", "str", "print", "printerr", @@ -141,6 +142,7 @@ int VisualScriptBuiltinFunc::get_func_argument_count(BuiltinFunc p_func) { case LOGIC_NEAREST_PO2: case OBJ_WEAKREF: case TYPE_OF: + case TEXT_CHAR: case TEXT_STR: case TEXT_PRINT: case TEXT_PRINTERR: @@ -362,6 +364,12 @@ PropertyInfo VisualScriptBuiltinFunc::get_input_value_port_info(int p_idx) const return PropertyInfo(Variant::STRING,"type"); } break; + case TEXT_CHAR: { + + return PropertyInfo(Variant::INT,"ascii"); + + + } break; case TEXT_STR: { return PropertyInfo(Variant::NIL,"value"); @@ -517,6 +525,7 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons t=Variant::BOOL; } break; + case TEXT_CHAR: case TEXT_STR: { t=Variant::STRING; @@ -975,6 +984,13 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func,const Variant** p_inp *r_return = ObjectTypeDB::type_exists(*p_inputs[0]); } break; + case VisualScriptBuiltinFunc::TEXT_CHAR: { + + CharType result[2] = {*p_inputs[0], 0}; + + *r_return=String(result); + + } break; case VisualScriptBuiltinFunc::TEXT_STR: { String str = *p_inputs[0]; @@ -1213,6 +1229,7 @@ void register_visual_script_builtin_func_node() { VisualScriptLanguage::singleton->add_register_func("functions/built_in/convert",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_CONVERT>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/typeof",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_OF>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/type_exists",create_builtin_func_node<VisualScriptBuiltinFunc::TYPE_EXISTS>); + VisualScriptLanguage::singleton->add_register_func("functions/built_in/char",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_CHAR>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/str",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_STR>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/print",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINT>); VisualScriptLanguage::singleton->add_register_func("functions/built_in/printerr",create_builtin_func_node<VisualScriptBuiltinFunc::TEXT_PRINTERR>); diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h index 000230d84f..8b0d70c1ea 100644 --- a/modules/visual_script/visual_script_builtin_funcs.h +++ b/modules/visual_script/visual_script_builtin_funcs.h @@ -57,6 +57,7 @@ public: TYPE_CONVERT, TYPE_OF, TYPE_EXISTS, + TEXT_CHAR, TEXT_STR, TEXT_PRINT, TEXT_PRINTERR, |