summaryrefslogtreecommitdiffstats
path: root/core/variant.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/variant.cpp')
-rw-r--r--core/variant.cpp60
1 files changed, 58 insertions, 2 deletions
diff --git a/core/variant.cpp b/core/variant.cpp
index 527a0d238f..472d6cf568 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -1556,6 +1556,18 @@ Variant::operator String() const {
return str;
} break;
+ case VECTOR2_ARRAY: {
+
+ DVector<Vector2> vec = operator DVector<Vector2>();
+ String str;
+ for(int i=0;i<vec.size();i++) {
+
+ if (i>0)
+ str+=", ";
+ str=str+Variant( vec[i] );
+ }
+ return str;
+ } break;
case VECTOR3_ARRAY: {
DVector<Vector3> vec = operator DVector<Vector3>();
@@ -3017,9 +3029,9 @@ String Variant::get_call_error_text(Object* p_base, const StringName& p_method,c
int errorarg=ce.argument;
err_text="Cannot convert argument "+itos(errorarg+1)+" from "+Variant::get_type_name(p_argptrs[errorarg]->get_type())+" to "+Variant::get_type_name(ce.expected)+".";
} else if (ce.error==Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS) {
- err_text="Expected "+itos(ce.argument)+" arguments.";
+ err_text="Method expected "+itos(ce.argument)+" arguments, but called with "+itos(p_argcount)+".";
} else if (ce.error==Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS) {
- err_text="Expected "+itos(ce.argument)+" arguments.";
+ err_text="Method expected "+itos(ce.argument)+" arguments, but called with "+itos(p_argcount)+".";
} else if (ce.error==Variant::CallError::CALL_ERROR_INVALID_METHOD) {
err_text="Method not found.";
} else if (ce.error==Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL) {
@@ -3036,3 +3048,47 @@ String Variant::get_call_error_text(Object* p_base, const StringName& p_method,c
}
return "'"+class_name+"::"+String(p_method)+"': "+err_text;
}
+
+
+String vformat(const String& p_text, const Variant& p1,const Variant& p2,const Variant& p3,const Variant& p4,const Variant& p5) {
+
+ Array args;
+ if (p1.get_type()!=Variant::NIL) {
+
+ args.push_back(p1);
+
+ if (p2.get_type()!=Variant::NIL) {
+
+ args.push_back(p2);
+
+ if (p3.get_type()!=Variant::NIL) {
+
+ args.push_back(p3);
+
+ if (p4.get_type()!=Variant::NIL) {
+
+ args.push_back(p4);
+
+ if (p5.get_type()!=Variant::NIL) {
+
+ args.push_back(p5);
+
+ }
+
+ }
+
+
+ }
+
+ }
+
+ }
+
+ bool error=false;
+ String fmt = p_text.sprintf(args,&error);
+
+ ERR_FAIL_COND_V(error,String());
+
+ return fmt;
+
+}