Game Development Community

Printing a matrix for debugging

by DiegoGdVU · in Torque 2D Beginner · 08/03/2013 (9:46 pm) · 2 replies

Hi im new to Torque2D, i read most of the tutorials and guides and now im trying to build a prototype for a game and i'm having some minor problem, i want to print a matrix on the console.log like this.

11101
10101
01010
11000

The problem is when a print it with echo() it appears like this

1
1
1
0
1
...

You get the idea, this is the code that im using it's part of larger file.

for(%yi=0; %yi<$size_y; %yi++)
 	{
 		for(%xi=0; %xi<$size_x; %xi++)
 		{
 			echo($grid[%yi,%xi]); 
 		}
 		echo("\n");
 	}

#1
08/03/2013 (10:08 pm)
As a rough idea off the top of my head, you will probably need to add an additional counter local variable. While the counter is less than 5, you keep combining the result of "n" into one string. You can combine strings together without whitespace with the @ operator (see here for some examples). Once the counter has registered that you have gone through the for loop 5 times, then use an echo() to print out the combined string value. Afterwards reset the string and counter and start all over.
#2
08/04/2013 (11:31 am)
Well yea i could do that, i was hoping there were other output functions that made my job easier, but i'm fine with that.

Thanks Mike