This is my beautiful code:
var Lasergun = pc.createScript('lasergun');
Lasergun.attributes.add('daray', {
type: 'entity'
});
Lasergun.prototype.initialize = function() {
this.canfire = true;
(this.daray).enabled = false;
};
Lasergun.prototype.update = function(dt) {
if(this.app.mouse.isPressed(pc.MOUSEBUTTON_LEFT))
{
// BROKEN PART SHOULD NOT FIRE
if(1 === 2);
{
(this.daray).enabled = true;
this.entity.sound.play("sound");
Bullets -= 1*dt;
}
}
else
{
(this.daray).enabled = false;
Bullets += 1*dt;
}
if(Bullets > 1)
{
Bullets = 1;
}
if(Bullets < 0)
{
Bullets = 0;
this.canfire = false;
}
console.log(this.canfire)
};
And yet, for some reason the if statement contained within the click check fires regardless of what I do. The click check works just fine, but the if statement within that other if statement seems to get ignored. Notice how I have the if statement check if 1 === 2. Obviously it is not but yet it runs anyway. Nothing I put in the if statement will make it not run. Why?