Game Development Community

probably a silly question but...

by Chris Sargent · in Torque 3D Professional · 01/14/2011 (9:02 pm) · 4 replies

I think the worst thing that I could have done was stop learning Torque script and move to prototyping in Unity. Now that I'm ready to port work back to Torque I have to learn / pick up where I left off on learning Torque Script. I'm following the math examples in the docs and here is my code:

// Print the sum of %a and %b

function addValues(%a, %b)
{
	%sum = %a + %b;
	echo ("Sum of " @ %a @ " + " @ %b @ ": ", %sum);
}


// Print the increment of %a

function incrementValue (%a)
{
	%original = %a;
	%a++;
	echo ("Single increment of " @ %original @ ": ", %a);
}

// Print the decrement of %a

function decrementValue (%a)
{
	%original = %a;
	%a--;
	echo ("Single decrement of " @ %original @ ": @, a%);
}

I can use the incrementValue function in the console, but when I type in decrementValue (5); in the console i get a message saying unable to find function decrementValue. My question is why? What did I do wrong?

Thanks!

#1
01/14/2011 (9:24 pm)

Line 25 reads a% instead of %a so the function probably fails to compile.
#2
01/14/2011 (9:48 pm)
Thanks Rene. I got that fixed but this still does not work. This is what I get in the console:

scripts/client/math.cs Line: 25 - syntax error
>>> Advanced script error report.  Line 25.
>>> Some error context, with ## on sides of error halt:
function incrementValue (%a)

{

^%original = %a;

^%a++;

^echo ("Single increment of " @ %original @ ": ", %a);

}



// Print the decrement of %a



function decrementValue (%a)

{

^%original = %a;

^%a--;

^echo ("Single decrement of " @ %original @ ": @, %a);

##}##


>>> Error report complete.

to me that looks like it is saying my closing bracket is wrong?
#3
01/14/2011 (9:53 pm)
Line 30, you are missing a closing quote around your colon.
#4
01/14/2011 (9:58 pm)
those 2 errors were it. I knew it was something simple. I shouldn't do this while tired. Thanks a bunch!