GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2018-09-19 11:17:16

Marcus12321
Member
Registered: 2018-09-19
Posts: 1

Simple Debug Message Script

/// 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

#2 2018-09-19 13:48:56

xot
Administrator
Registered: 2007-08-18
Posts: 1,189

Re: Simple Debug Message Script

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

#3 2018-09-19 20:00:32

idealcastle
Member
Registered: 2018-09-12
Posts: 9

Re: Simple Debug Message Script

I like this. I will try it out!

Offline

#4 2018-11-05 10:29:20

gnysek
Member
Registered: 2011-12-29
Posts: 17

Re: Simple Debug Message Script

In gms2 you can do

s+= (i > 0 ", " : "") + string(argument[i]);

which make it even more beautiful smile

Offline

#5 2018-11-09 02:01:47

xot
Administrator
Registered: 2007-08-18
Posts: 1,189

Re: Simple Debug Message Script

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

Board footer

Powered by FluxBB