Add new "push_*()" functions to GDScript
This commit is contained in:
parent
13eaded911
commit
1ca61a35d8
2 changed files with 49 additions and 5 deletions
|
@ -106,6 +106,8 @@ const char *GDScriptFunctions::get_func_name(Function p_func) {
|
|||
"printerr",
|
||||
"printraw",
|
||||
"print_debug",
|
||||
"push_error",
|
||||
"push_warning",
|
||||
"var2str",
|
||||
"str2var",
|
||||
"var2bytes",
|
||||
|
@ -707,13 +709,40 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
|||
|
||||
ScriptLanguage *script = GDScriptLanguage::get_singleton();
|
||||
if (script->debug_get_stack_level_count() > 0) {
|
||||
str += "\n\t";
|
||||
str += "At: " + script->debug_get_stack_level_source(0) + ":" + itos(script->debug_get_stack_level_line(0)); // + " in function '" + script->debug_get_stack_level_function(0) + "'";
|
||||
str += "\n At: " + script->debug_get_stack_level_source(0) + ":" + itos(script->debug_get_stack_level_line(0)) + ":" + script->debug_get_stack_level_function(0) + "()";
|
||||
}
|
||||
|
||||
print_line(str);
|
||||
r_ret = Variant();
|
||||
} break;
|
||||
case PUSH_ERROR: {
|
||||
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();
|
||||
break;
|
||||
}
|
||||
|
||||
String message = *p_args[0];
|
||||
ERR_PRINTS(message);
|
||||
r_ret = Variant();
|
||||
} break;
|
||||
case PUSH_WARNING: {
|
||||
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();
|
||||
break;
|
||||
}
|
||||
|
||||
String message = *p_args[0];
|
||||
WARN_PRINTS(message);
|
||||
r_ret = Variant();
|
||||
} break;
|
||||
case VAR_TO_STR: {
|
||||
VALIDATE_ARG_COUNT(1);
|
||||
String vars;
|
||||
|
@ -1753,12 +1782,26 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
|
|||
mi.flags |= METHOD_FLAG_VARARG;
|
||||
return mi;
|
||||
|
||||
} break;
|
||||
case PUSH_ERROR: {
|
||||
|
||||
MethodInfo mi(Variant::NIL, "push_error", PropertyInfo(Variant::STRING, "message"));
|
||||
mi.return_val.type = Variant::NIL;
|
||||
return mi;
|
||||
|
||||
} break;
|
||||
case PUSH_WARNING: {
|
||||
|
||||
MethodInfo mi(Variant::NIL, "push_warning", PropertyInfo(Variant::STRING, "message"));
|
||||
mi.return_val.type = Variant::NIL;
|
||||
return mi;
|
||||
|
||||
} break;
|
||||
case VAR_TO_STR: {
|
||||
|
||||
MethodInfo mi("var2str", PropertyInfo(Variant::NIL, "var", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT));
|
||||
mi.return_val.type = Variant::STRING;
|
||||
return mi;
|
||||
|
||||
} break;
|
||||
case STR_TO_VAR: {
|
||||
|
||||
|
@ -1768,10 +1811,10 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
|
|||
return mi;
|
||||
} break;
|
||||
case VAR_TO_BYTES: {
|
||||
|
||||
MethodInfo mi("var2bytes", PropertyInfo(Variant::NIL, "var", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_NIL_IS_VARIANT));
|
||||
mi.return_val.type = Variant::POOL_BYTE_ARRAY;
|
||||
return mi;
|
||||
|
||||
} break;
|
||||
case BYTES_TO_VAR: {
|
||||
|
||||
|
|
|
@ -97,6 +97,8 @@ public:
|
|||
TEXT_PRINTERR,
|
||||
TEXT_PRINTRAW,
|
||||
TEXT_PRINT_DEBUG,
|
||||
PUSH_ERROR,
|
||||
PUSH_WARNING,
|
||||
VAR_TO_STR,
|
||||
STR_TO_VAR,
|
||||
VAR_TO_BYTES,
|
||||
|
@ -117,7 +119,6 @@ public:
|
|||
LEN,
|
||||
IS_INSTANCE_VALID,
|
||||
FUNC_MAX
|
||||
|
||||
};
|
||||
|
||||
static const char *get_func_name(Function p_func);
|
||||
|
|
Loading…
Reference in a new issue