Blockland Forums > Modification Help
Syntax error: Projectile Changing function
takato14:
--- Quote from: Chrono on December 04, 2010, 07:22:12 PM ---Why did you add an extra } there after the Mission cleanup?
Also change
if(!%health = 100)
to
if(%health != 100)
and even if you were not using a !, it would be ==, not =.
--- End quote ---
So that explains why its still not working even after I stopped the syntax errors. Thank you.
Bauklotz:
Cleaned-up code:
--- Code: ---function masterImage::onFire(%this, %obj, %slot) {
if(%obj.getDamageLevel() > 0) {
%p = new Projectile(MasterProjectile) {
datablock = MasterProjectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
else {
%p = new Projectile(MasterProjectileFull) {
datablock = MasterProjectileFull;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
}
--- End code ---
takato14:
--- Quote from: Bauklotz on January 13, 2011, 08:38:52 AM ---Cleaned-up code:
--- Code: ---function masterImage::onFire(%this, %obj, %slot) {
if(%obj.getDamageLevel() > 0) {
%p = new Projectile(MasterProjectile) {
datablock = MasterProjectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
else {
%p = new Projectile(MasterProjectileFull) {
datablock = MasterProjectileFull;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
}
--- End code ---
--- End quote ---
Erm, that works, but it screws up the projectile lifetime...
Like, it spawns the projectiles, but they vanish before they can hit anything. I spawned the projectiles manually (set the gun to fire them instead) and they work. Whats going on?
takato14:
Uber-huge mofo pagebump.