Game Development Community

Recursivity in scripts !

by Claude-Alain Fournier · in Torque Game Engine · 10/20/2004 (1:41 am) · 2 replies

Hi,

I made this small code to test recursivity :

function testRecursiveStart()
{
	echo("Start Test") ;
	testRecursive(1) ;
	echo("Stop Test") ;
}

function testRecursive(%i)
{
	if(%i == 2286)
	{
		echo("Reached Bottom") ;
		return ;
	}

	echo("Open Level : " @ %i) ;
	%i++ ;

	testRecursive(%i) ;
		
	echo("Close Level : " @ %i) ;
}

Good new is it work in Torque script and can recurse to quite a few levels. The limit I found is 2286 levels, one more and I get a "stack overflow" assert.

It will be interesting to know if this is a fixed limit or dependent on other parameters like memory, operating system etc... So if a few peoples could test it, I think it will give some interesting informations on the recursivity limits.

It will be nice is some GG developer can comment on this.

Regards,

CAF

#1
10/21/2004 (1:09 am)
It's not hard-coded or engine limited, just limited by your system specs / environment. :)
#2
10/21/2004 (7:40 am)
Thanks Josh.