diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index cccf09c58ee2..ce91e7dff38f 100644 --- a/modules/gdscript/gdscript_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -105,6 +105,7 @@ const char *GDScriptFunctions::get_func_name(Function p_func) { "prints", "printerr", "printraw", + "print_debug", "var2str", "str2var", "var2bytes", @@ -702,6 +703,23 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_ r_ret = Variant(); } break; + case TEXT_PRINT_DEBUG: { + String str; + for (int i = 0; i < p_arg_count; i++) { + + str += p_args[i]->operator String(); + } + + 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"; + print_line(str); + r_ret = Variant(); + } break; case VAR_TO_STR: { VALIDATE_ARG_COUNT(1); String vars; @@ -1732,6 +1750,14 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) { mi.flags |= METHOD_FLAG_VARARG; return mi; + } break; + case TEXT_PRINT_DEBUG: { + + MethodInfo mi("print_debug"); + mi.return_val.type = Variant::NIL; + mi.flags |= METHOD_FLAG_VARARG; + return mi; + } break; case VAR_TO_STR: { MethodInfo mi("var2str", PropertyInfo(Variant::NIL, "var")); diff --git a/modules/gdscript/gdscript_functions.h b/modules/gdscript/gdscript_functions.h index 899a7ebd252a..a29f06e8396e 100644 --- a/modules/gdscript/gdscript_functions.h +++ b/modules/gdscript/gdscript_functions.h @@ -96,6 +96,7 @@ public: TEXT_PRINT_SPACED, TEXT_PRINTERR, TEXT_PRINTRAW, + TEXT_PRINT_DEBUG, VAR_TO_STR, STR_TO_VAR, VAR_TO_BYTES,