You are not logged in.
Pages: 1
/// dbg(arguments[]);
//
// Prints a comma delimited show_debug_message of the variables provided.
//
// Nothing spectacular, just quicker than typing out show_debug_message().
//
// Also, it is possible to just copy and paste the portion of a function in
// parenthesis and put it in a dbg statement.
//
// For example, you can take this line:
// draw_sprite_stretched(vSprite2,1,vX+W2[0],vY, vWidth-(W2[0]+W2[2]),vSpriteH2);
//
// And easily display it like this:
// dbg(vSprite2,1,vX+W2[0],vY, vWidth-(W2[0]+W2[2]),vSpriteH2);
//
// GMS2 Header:
//
/// @func dbg(arguments[])
/// @desc Prints the variables to the debug window.
/// @param {string} arguments Any number of variables.
///
var s=date_time_string(date_current_datetime()) + ": ";
var i=0;
repeat (argument_count-1) {
s+=string(argument[i]) + ", ";
i++;
}
s+=string(argument[i]);
show_debug_message(s);
Offline
Nice. I don't know why I've never made something this useful for myself.
Thanks for the submission, Marcus12321, and welcome to the forums.
Abusing forum power since 1986.
Offline
I like this. I will try it out!
Offline
In gms2 you can do
s+= (i > 0 ", " : "") + string(argument[i]);
which make it even more beautiful
Offline
I'm certain you meant:
s+= (i > 0 ? ", " : "") + string(argument[i]);
Just a little typo. I'd wrap it in a for
statement and be pretty satisfied ... even if I'm not a fan of passing strings to string()
.
Abusing forum power since 1986.
Offline
s+= (i > 0 ? ", " : "") + (is_real(argument[i]) ? string(argument[i]) : ("\"" + string(argument[i]) + "\""));
Then you can differ number from string, may be helpful in some debug cases.
Offline
Including that last string()
sort of defeats the purpose! But I like the use of quotes to distinguish it as a string.
Looks like the syntax highlighter doesn't understand escaped quotes. I'll work on a fix. Fixed.
Last edited by xot (2019-03-09 06:19:40)
Abusing forum power since 1986.
Offline
Pages: 1