aboutsummaryrefslogtreecommitdiff
path: root/modules/gdscript/gd_functions.cpp
diff options
context:
space:
mode:
authorAnton Yabchinskiy2015-02-17 15:57:24 +0300
committerAnton Yabchinskiy2015-02-17 15:57:24 +0300
commite024ff89b224f803fe335efa95d3e99bffc3423f (patch)
tree84ca5323c97ef24cfcae202447ac6967783e9248 /modules/gdscript/gd_functions.cpp
parent6f93e6812edaf6c8c79c28dadbe5f1c4a8ced93e (diff)
parent2bea642583efeb68886e71950384f297f2d7ee12 (diff)
downloadgodot-e024ff89b224f803fe335efa95d3e99bffc3423f.tar.gz
godot-e024ff89b224f803fe335efa95d3e99bffc3423f.tar.zst
godot-e024ff89b224f803fe335efa95d3e99bffc3423f.zip
Diffstat (limited to 'modules/gdscript/gd_functions.cpp')
-rw-r--r--modules/gdscript/gd_functions.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index fcfbbb04d..b616d8f22 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -89,6 +89,8 @@ const char *GDFunctions::get_func_name(Function p_func) {
"printt",
"printerr",
"printraw",
+ "var2str",
+ "str2var",
"range",
"load",
"inst2dict",
@@ -577,10 +579,23 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
r_ret=Variant();
} break;
+ case VAR_TO_STR: {
+ VALIDATE_ARG_COUNT(1);
+ r_ret=p_args[0]->get_construct_string();
+ } break;
+ case STR_TO_VAR: {
+ VALIDATE_ARG_COUNT(1);
+ if (p_args[0]->get_type()!=Variant::STRING) {
+ r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.argument=0;
+ r_error.expected=Variant::STRING;
+ r_ret=Variant();
+ return;
+ }
+ Variant::construct_from_string(*p_args[0],r_ret);
+ } break;
case GEN_RANGE: {
-
-
switch(p_arg_count) {
case 0: {
@@ -861,7 +876,6 @@ void GDFunctions::call(Function p_func,const Variant **p_args,int p_arg_count,Va
}
}
-
r_ret = gdscr->_new(NULL,0,r_error);
} break;
@@ -1224,6 +1238,18 @@ MethodInfo GDFunctions::get_info(Function p_func) {
return mi;
} break;
+ case VAR_TO_STR: {
+ MethodInfo mi("var2str",PropertyInfo(Variant::NIL,"var"));
+ mi.return_val.type=Variant::STRING;
+ return mi;
+
+ } break;
+ case STR_TO_VAR: {
+
+ MethodInfo mi("str2var:var",PropertyInfo(Variant::STRING,"string"));
+ mi.return_val.type=Variant::NIL;
+ return mi;
+ } break;
case GEN_RANGE: {
MethodInfo mi("range",PropertyInfo(Variant::NIL,"..."));