Author Topic: unmount object error  (Read 1643 times)

I tried changing my lego spear to throwing it on charged fire. I wanted it to unmount from your and on the charged fire so I simply added the unmount object script, but it gives me an error. I dont know enough about scripting yet to understand my mistake.

Heres the code:
Code: [Select]
function lkspImage::onChargedFire(%this,%obj,%slot)
{
if((%obj.lastFireTime+%this.minShotTime) > getSimTime())
return;
%obj.lastFireTime = getSimTime();
     
%obj.playThread(2, spearThrow);

%projectile = lkspchargeProjectile;
%spread = 0.0;
%shellcount = 1;

for(%shell=0; %shell<%shellcount; %shell++)
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = lkspchargeProjectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
{
%obj.unMountImage(%slot);
};
MissionCleanup.add(%p);
}
return %p;
}
}

Heres the error:
Code: [Select]
Loading Add-On: Weapon_Legoknights (CRC:-876017223)
Add-Ons/Weapon_Legoknights/Weapon_lksp.cs Line: 254 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^^%velocity = MatrixMulVector(%mat, %velocity);



^^%p = new (%this.projectileType)()

^^{

^^^dataBlock = lkspchargeProjectile;

^^^initialVelocity = %velocity;

^^^initialPosition = %obj.getMuzzlePoint(%slot);

^^^sourceObject = %obj;

^^^sourceSlot = %slot;

^^^client = %obj.client;

^^^{##
##
^^^^%obj.unMountImage(%slot);

^^^};

^^^MissionCleanup.add(%p);

^^}

^^return %p;

^}

}
>>> Error report complete.

I don't see what the { and the }; between the unmount are doing. There isn't anything you are checking or adding, so removed them and see what happens.

Get rid of the { above the unmount line and the } below the mission cleanup line.

I don't see what the { and the }; between the unmount are doing. There isn't anything you are checking or adding, so removed them and see what happens.
I get this error with heeds idea:
Code: [Select]
Loading Add-On: Weapon_Legoknights (CRC:1062757482)
Add-Ons/Weapon_Legoknights/Weapon_lksp.cs Line: 254 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^^%velocity = MatrixMulVector(%mat, %velocity);



^^%p = new (%this.projectileType)()

^^{

^^^dataBlock = lkspchargeProjectile;

^^^initialVelocity = %velocity;

^^^initialPosition = %obj.getMuzzlePoint(%slot);

^^^sourceObject = %obj;

^^^sourceSlot = %slot;

^^^client = %obj.client;

^^^^%obj.##u##nMountImage(%slot);

^^};

^^^MissionCleanup.add(%p);

^}

^return %p;

}
>>> Error report complete.

Tried oher way:
Code: [Select]
Loading Add-On: Weapon_Legoknights (CRC:1745319207)
Add-Ons/Weapon_Legoknights/Weapon_lksp.cs Line: 255 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^^%velocity = MatrixMulVector(%mat, %velocity);



^^%p = new (%this.projectileType)()

^^{

^^^dataBlock = lkspchargeProjectile;

^^^initialVelocity = %velocity;

^^^initialPosition = %obj.getMuzzlePoint(%slot);

^^^sourceObject = %obj;

^^^sourceSlot = %slot;

^^^client = %obj.client;

^^^

^^^^%obj.##u##nMountImage(%slot);

^^^};

^^^MissionCleanup.add(%p);

^^

^^return %p;

^}

}
>>> Error report complete.
« Last Edit: February 19, 2010, 10:57:16 PM by Bizzarre »

Move the unmountimage line down a line.

Move the unmountimage line down a line.
Yea, do that. That thing is defining a projectile and it probably doesn't know what you are trying to do. You have to put it after the missioncleanup, maybe.

Move the unmountimage line down a line.
I'm confused as to what that means, I pressed enter and got an error, then I moved it above mission cleanup and got an error.

I'm confused as to what that means, I pressed enter and got an error, then I moved it above mission cleanup and got an error.
What's the error when it's above mission cleanup?

What's the error when it's above mission cleanup?
Code: [Select]
Loading Add-On: Weapon_Legoknights (CRC:953420270)
Add-Ons/Weapon_Legoknights/Weapon_lksp.cs Line: 262 - Syntax error.
>>> Some error context, with ## on sides of error halt:
^^^dataBlock = lkspchargeProjectile;

^^^initialVelocity = %velocity;

^^^initialPosition = %obj.getMuzzlePoint(%slot);

^^^sourceObject = %obj;

^^^sourceSlot = %slot;

^^^client = %obj.client;

^^^

^^^};

^^^%obj.unMountImage(%slot);



^^^MissionCleanup.add(%p);

^^}

^^return %p;

^}

}##
>>> Error report complete.

Have you changed anything else? I'm baffled.

Have you changed anything else? I'm baffled.
No, all I did was add the unmount object line.

Oh, I didn't notice before, but the missioncleanup line is also inside of the projectile. Use this (I've cleaned up some other parts too):
Code: [Select]
function lkspImage::onChargedFire(%this,%obj,%slot)
{
if((%obj.lastFireTime+%this.minShotTime) > getSimTime())
return;
%obj.lastFireTime = getSimTime();

%obj.playThread(2, spearThrow);

%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %this.projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%p = new projectile()
{
dataBlock = lkspchargeProjectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
%obj.unMountImage(%slot);
MissionCleanup.add(%p);
return %p;
}
EDIT: fixed the speed...
« Last Edit: February 24, 2010, 04:07:34 PM by Amade »


It doesnt unmount the lksp image :/