Ennoying syntax error
by Johnathan Moore · in Torque Game Engine · 10/30/2005 (5:23 am) · 9 replies
Could someone solve this syntax error for me I cant see anything wrong with it
function GameConnection::createPlayer(%this, %spawnPoint,%Char)
{
if (%this.player > 0) {
// The client should not have a player currently
// assigned. Assigning a new one could result in
// a player ghost.
error( "Attempting to create an angus ghost!" );
}
Switch(%Char)
case 1:
// Create the player object
%player = new Player() {
dataBlock = TerroristBody;
client = %this;
};
MissionCleanup.add(%player);
// Player setup...
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
// Update the camera to start with the player
%this.camera.setTransform(%player.getEyeTransform());
// Give the client control of the player
%this.player = %player;
%this.setControlObject(%player);
// Set Equip
togglehelmet();
%player.setSkinName(iraq);
case 2:
// Create the player object
%player = new Player() {
datablock = BrittishBody;
client = %this;
};
MissionCleanup.add(%player);
// Player setup...
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
// Update the camera to start with the player
%this.camera.setTransform(%player.getEyeTransform());
// Give the client control of the player
%this.player = %player;
%this.setControlObject(%player);
// Set Equip
togglehelmet();
%player.setSkinName(jungle1);
Case 3:
// Create the player object
%player = new Player() {
dataBlock = SASBody;
client = %this;
};
MissionCleanup.add(%player);
// Player setup...
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
// Update the camera to start with the player
%this.camera.setTransform(%player.getEyeTransform());
// Give the client control of the player
%this.player = %player;
%this.setControlObject(%player);
// Set Equip
togglegasmask();
%player.setSkinName(gign);
case 4:
// Create the player object
%player = new Player() {
dataBlock = AmericanBody;
client = %this;
};
MissionCleanup.add(%player);
// Player setup...
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
// Update the camera to start with the player
%this.camera.setTransform(%player.getEyeTransform());
// Give the client control of the player
%this.player = %player;
%this.setControlObject(%player);
// Set Equip
togglegasmask();
%player.setSkinName(classic);
}>>> Advanced script error report. Line 25.
>>> Some error context, with ## on sides of error halt:
error( "Attempting to create an angus ghost!" );
}
Switch(%Char)
case ##1##:
// Create the player object
%player = new Player() {
dataBlock = TerroristBody;
>>> Error report complete.About the author
Been tinkering with this since I was young.
#2
10/30/2005 (6:07 am)
Kl thanks, now i look like a dunce :p
#3
10/30/2005 (6:23 am)
It still says there is still a syntax error>>> Advanced script error report. Line 19.
>>> Some error context, with ## on sides of error halt:
error( "Attempting to create an angus ghost!" );
}
Switch(%Char)
{##
##
case 1:
// Create the player object
%player = new Player() {
>>> Error report complete.
#4
case "1":
Also, assuming that you cut/pasted the entire function, you are missing at least one ending } for the function itself.
10/30/2005 (10:10 am)
Try using switch$() ("switch string") and put your individual case matches in quotes, such as:case "1":
Also, assuming that you cut/pasted the entire function, you are missing at least one ending } for the function itself.
#5
10/31/2005 (2:07 pm)
IE Replace the entire funtion withfunction GameConnection::createPlayer(%this, %spawnPoint,%Char)
{
if (%this.player > 0) {
// The client should not have a player currently
// assigned. Assigning a new one could result in
// a player ghost.
error( "Attempting to create an angus ghost!" );
}
switch(%Char)
{
case 1:
// Create the player object
%player = new Player() {
dataBlock = TerroristBody;
client = %this;
};
MissionCleanup.add(%player);
// Player setup...
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
// Update the camera to start with the player
%this.camera.setTransform(%player.getEyeTransform());
// Give the client control of the player
%this.player = %player;
%this.setControlObject(%player);
// Set Equip
togglehelmet();
%player.setSkinName(iraq);
case 2:
// Create the player object
%player = new Player() {
datablock = BrittishBody;
client = %this;
};
MissionCleanup.add(%player);
// Player setup...
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
// Update the camera to start with the player
%this.camera.setTransform(%player.getEyeTransform());
// Give the client control of the player
%this.player = %player;
%this.setControlObject(%player);
// Set Equip
togglehelmet();
%player.setSkinName(jungle1);
Case 3:
// Create the player object
%player = new Player() {
dataBlock = SASBody;
client = %this;
};
MissionCleanup.add(%player);
// Player setup...
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
// Update the camera to start with the player
%this.camera.setTransform(%player.getEyeTransform());
// Give the client control of the player
%this.player = %player;
%this.setControlObject(%player);
// Set Equip
togglegasmask();
%player.setSkinName(gign);
case 4:
// Create the player object
%player = new Player() {
dataBlock = AmericanBody;
client = %this;
};
MissionCleanup.add(%player);
// Player setup...
%player.setTransform(%spawnPoint);
%player.setShapeName(%this.name);
// Update the camera to start with the player
%this.camera.setTransform(%player.getEyeTransform());
// Give the client control of the player
%this.player = %player;
%this.setControlObject(%player);
// Set Equip
togglegasmask();
%player.setSkinName(classic);
}
}
#6
11/03/2005 (1:12 pm)
Hmmm well it gives a different syntax error now>>> Advanced script error report. Line 117.
>>> Some error context, with ## on sides of error halt:
togglehelmet();
%player.setSkinName(jungle1);
Case 3:##
##
// Create the player object
%player = new Player() {
dataBlock = SASBody;
>>> Error report complete.
#7
You were using caps for all of those (Switch(%var) should be switch(%var)) and the engine doesn't like that. Just like you should never capitalize "Function name(blah)" never capitalize things like that ;)
Hope that helps ;)
11/03/2005 (1:24 pm)
Ok well nobody has said this yet but: DON'T USE CAPS (oh the irony)You were using caps for all of those (Switch(%var) should be switch(%var)) and the engine doesn't like that. Just like you should never capitalize "Function name(blah)" never capitalize things like that ;)
Hope that helps ;)
#8
11/03/2005 (1:25 pm)
Ok thanks never knew that
#9
11/04/2005 (12:28 pm)
ROFL. Didn't notice that. Torque Script should be treated like C++ where everything is case sensitive. The only difference between the two in the case sensitive way is that Torque Script does not use case sensitive variables. (Even though I think it should.)
Torque Owner Matt "Mr. Pig" Razza
function GameConnection::createPlayer(%this, %spawnPoint,%Char) { if (%this.player > 0) { // The client should not have a player currently // assigned. Assigning a new one could result in // a player ghost. error( "Attempting to create an angus ghost!" ); } Switch(%Char) { case 1: // Create the player object %player = new Player() { dataBlock = TerroristBody; client = %this; }; MissionCleanup.add(%player); // Player setup... %player.setTransform(%spawnPoint); %player.setShapeName(%this.name); // Update the camera to start with the player %this.camera.setTransform(%player.getEyeTransform()); // Give the client control of the player %this.player = %player; %this.setControlObject(%player); // Set Equip togglehelmet(); %player.setSkinName(iraq); case 2: // Create the player object %player = new Player() { datablock = BrittishBody; client = %this; }; MissionCleanup.add(%player); // Player setup... %player.setTransform(%spawnPoint); %player.setShapeName(%this.name); // Update the camera to start with the player %this.camera.setTransform(%player.getEyeTransform()); // Give the client control of the player %this.player = %player; %this.setControlObject(%player); // Set Equip togglehelmet(); %player.setSkinName(jungle1); Case 3: // Create the player object %player = new Player() { dataBlock = SASBody; client = %this; }; MissionCleanup.add(%player); // Player setup... %player.setTransform(%spawnPoint); %player.setShapeName(%this.name); // Update the camera to start with the player %this.camera.setTransform(%player.getEyeTransform()); // Give the client control of the player %this.player = %player; %this.setControlObject(%player); // Set Equip togglegasmask(); %player.setSkinName(gign); case 4: // Create the player object %player = new Player() { dataBlock = AmericanBody; client = %this; }; MissionCleanup.add(%player); // Player setup... %player.setTransform(%spawnPoint); %player.setShapeName(%this.name); // Update the camera to start with the player %this.camera.setTransform(%player.getEyeTransform()); // Give the client control of the player %this.player = %player; %this.setControlObject(%player); // Set Equip togglegasmask(); %player.setSkinName(classic); }