Game Development Community

T2D Basic Tutorial, why doesn't my script function?

by Marcus Aurelius · in Torque Game Builder · 06/07/2005 (11:54 pm) · 11 replies

Hi, I just bought T2D today and have been digging into the basic Tutorial pdf provided in the docs folder. I followed the instructions and the first couple of code segments seemed to work fine for me; I got the player & enemy spaceships to appear in the Torque Home-window and I also added the code to make the enemy craft fly towards our players' ship. I then proceeded to add the keybinding code but it just doesn't seem to work.

The Tutorial says I should place the "playerUp()" function below the "setupT2DScene()" function...where exactly is this? I cut and pasted the code snippet in every location without success....

Here's a quick screenshot of what I've got so far:

http://shojin.com/files/T2DTutorialCode.jpg

Does anyone know what I might be doing wrong?

#1
06/08/2005 (12:03 am)
Yes. You never finish your setup2DScene function. Try putting a single end-brace, '}', around line 116

Gary (-;
#2
06/08/2005 (12:22 am)
Thanks for your reply, I added the suggested end brace at line 116 but the w key still does not do anything.... Is there anything else I could try?

Also, I find it much easier and more intuitive to work visually rather than on the coding level. Isn't there a way to do all this in the Torque editor itself, like a logical editor? If not are the developers planning to include this feature with the final release? ..At least maybe for the most basic functions?

Thanks again!

-Marc
#3
06/08/2005 (12:36 am)
Check your console, and console.log. Your code probably has another error in it causing it to not compile right. There will be a pair of ##s around the bit where Torque choked, but it's not impossible the error occured before that point.

Gary (-;
#4
06/08/2005 (1:22 am)
Hmm, I checked the console.log file but it does not note any errors pertaining to the code I was working with....

-Marc
#5
06/08/2005 (1:44 am)
Can you post the console.log file?
#6
06/08/2005 (9:48 am)
If theres any errors in that script file it will flag it in your console with red text, if there are any errors you need to fix them otherwise it won't compile the script file again and will just use the previous compiled version
#7
06/08/2005 (3:25 pm)
Matthew & Gary,

Ahh, thank you! Your posts were very helpful. It seems I had a latent end brace } at line 134 which was messing with the last bit of code I had written. It also helps knowing that erronous scripts don't get compiled...I was experiencing weird things.

I got that w key to work, thanks again to everyone for your time and help!

-Marc
#8
06/09/2005 (11:10 pm)
Hi, I'm sorry to keep bothering you guys about this Getting Started tutorial; I seem to have gotten myself stuck again. I tried hard to figure this out on my own but I'm afraid it's beyond me at this point.

The thing is I can't get my spaceship to fire a missile. I'm fairly positive that I wrote the code exactly as it was given in the tutorial. The console.log file says there are errors but I can't figure out why...anyway here is the error report from the console.log file:

Compiling T2D/client/client.cs...
T2D/client/client.cs Line: 88 - Syntax error.
>>> Advanced script error report. Line 175.
>>> Some error context, with ## on sides of error halt:
// --------------------------------------------------------------------

function ##S##etupImages()

^{

^// Create an image for the player ship

^datablock fxImageMapDatablock2D(playershipImageMap)
>>> Error report complete.


So what are the errors with line 88 and 175? I'll post them for you... here are lines 88 through to line 96:

function SetupImages()
{
// Create an image for the player ship
datablock fxImageMapDatablock2D(playershipImageMap)

{
mode = full;
textureName = "~/client/images/playerShip";
};

And lines 168 through to 175:

// Create an enemy missile and fire it
%enemyFire = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
%enemyFire.setPosition( %enemy.getPosition() );
%enemyFire.setSize( "3 1.5" );
%enemyFire.setImageMap( enemymissileImageMap );
%enemyFire.setLinearVelocityX( -35 );
%enemyFire.setWorldLimit( kill, "-60 -40 60 40" );
}

Does anyone know what I'm doing wrong? Thank you for your time!

All the best-

-Marc
#9
06/09/2005 (11:40 pm)
It's probably something a bit before that. Typically, missing a ; or { or } will cause the error to appear a few lines after the line that has the problem.
#10
06/10/2005 (12:09 am)
Philip, thank you. I got it to work now...I missed another end brace on the previous function. Your post helped me look in the right place....I'm learning allot from you guys already.

Does anyone know if the developers are working on a visually based editor native to the Torque2D editor? Such a feature would enhance the game making experience enormously!

-Marc
#11
06/10/2005 (12:34 am)
There are plugins for some editors that will give you colour highlighted text. I don't use any so can't recommend one, but have a browse through the forums, as various IDEs and text editors have been discussed in other threads.