Parse error?
by Chris Farley · in Torque Game Engine · 11/30/2006 (4:06 pm) · 1 replies
I amde a script file for my game to make my ship move, iv been following the examples on the tutorials to create a shooter game.
this is what is contained in my player.cs file:
the error report on the console says
line 1 parse error.
advanced script error report. Line 1.
some error context, with ## on sides of error halt:
this is what is contained in my player.cs file:
function playerShip::onLevelLoaded(%this, %scenegraph)
{
//set the player's ship name to the instance
$pShip = %this;
moveMap.bindCmd(keyboard, "w", "pShipUp();", "pShipUpStop();");
moveMap.bindCmd(keyboard, "s", "pShipDown();", "pShipDownStop();");
moveMap.bindCmd(keyboard, "a", "pShipLeft();", "pShipLeftStop();");
moveMap.bindCmd(keyboard, "d", "pShipRight();", "pShipRightStop();");
}
function playerShip::updateMovement(%this)
{
if(%this.moveLeft)
{
%this.setLinearVelocityX( -$pShip.hSpeed );
}
if(%this.moveRight)
{
%this.setLinearVelocityX( $pShip.hSpeed );
}
if(%this.moveUp)
{
%this.setLinearVelocityY( -$pShip.vSpeed );
}
if(%this.moveDown)
{
%this.setLinearVelocityY( $pShip.vSpeed );
}
if(!%this.moveLeft && !%this.moveRight)
{
%this.setLinearVelocityX( 0 );
}
if(!%this.moveUp && !%this.moveDown)
{
%this.setLinearVelocityY( 0 );
}
}
function pShipUp()
{
$pShip.moveUp = true;
$pShip.updateMovement();
}
function pShipDown()
{
$pShip.moveDown = true;
$pShip.updateMovement();
}
function pShipLeft()
{
$pShip.moveLeft = true;
$pShip.updateMovement();
}
function pShipRight()
{
$pShip.moveRight = true;
$pShip.updateMovement();
}
function pShipLeftStop()
{
$pShip.moveLeft = false;
$pShip.updateMovement();
}
function pShipRightStop()
{
$pShip.moveRight = false;
$pShip.updateMovement();
}
function pShipUpStop()
{
$pShip.moveUp = false;
$pShip.updateMovement();
}
function pShipDownStop()
{
$pShip.moveDown = false;
$pShip.updateMovement();
}the error report on the console says
line 1 parse error.
advanced script error report. Line 1.
some error context, with ## on sides of error halt:
About the author
Joseph Sullivan
click your ship in the level editer and then click the edit tab to the far right, scroll down to 'scripting' then add the name and class
class = playerShip
name = pShip
that should do ya.