Would someone please tell me what I'm doing wrong here
by Jason Coggins · in Torque Game Builder · 07/01/2006 (7:58 pm) · 2 replies
TGB says there is a syntax error in the following code but I cannot find it.
function enemyShip::fireMissile(%this)
{
%this.enemyMissile = new t2dStaticSprite()
{
$fireSound = alxPlay(fireSound);
scenegraph = %this.scenegraph;
class = enemyMissile;
missileSpeed=%this.missileSpeed;
enemy = %this;
}
%this.enemyMissile.fire();
%this.schedule(getRandom(%this.minShoot, %this.maxShoot), "fireMissile");
}
Jason
function enemyShip::fireMissile(%this)
{
%this.enemyMissile = new t2dStaticSprite()
{
$fireSound = alxPlay(fireSound);
scenegraph = %this.scenegraph;
class = enemyMissile;
missileSpeed=%this.missileSpeed;
enemy = %this;
}
%this.enemyMissile.fire();
%this.schedule(getRandom(%this.minShoot, %this.maxShoot), "fireMissile");
}
Jason
About the author
#2
In fact, I'm not sure what you're doing with that line, but it won't work as it is anyway. Try removing the '$' from the beginning. Also, add a semicolon (;) after the first closing curly brace. Anyway, TGB seems to compile it that way for me, but I haven't tried testing it any further than getting it to exec
07/01/2006 (8:15 pm)
$firesound is a global scope variable and will not work in a datablock definition such as you are using here.In fact, I'm not sure what you're doing with that line, but it won't work as it is anyway. Try removing the '$' from the beginning. Also, add a semicolon (;) after the first closing curly brace. Anyway, TGB seems to compile it that way for me, but I haven't tried testing it any further than getting it to exec
function enemyShip::fireMissile(%this)
{
%this.enemyMissile = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
class = enemyMissile;
missileSpeed=%this.missileSpeed;
enemy = %this;
fireSound = alxPlay(fireSound);
};
%this.enemyMissile.fire();
%this.schedule(getRandom(%this.minShoot, %this.maxShoot), "fireMissile");
}
Torque Owner Fenrir Wolf
function enemyShip::fireMissile(%this) { %this.enemyMissile = new t2dStaticSprite() { $fireSound = alxPlay(fireSound); scenegraph = %this.scenegraph; class = enemyMissile; missileSpeed=%this.missileSpeed; enemy = %this; }; // <------- NEED ME! %this.enemyMissile.fire(); %this.schedule(getRandom(%this.minShoot, %this.maxShoot), "fireMissile"); }All objects/datablocks that are created using the new method in script require that extra semicolon at the end of the definition.