The script is borked, and I'm stuck.
Here's what the script must do:
It has to rotate the two cogs 1/2 as much as the turret, along the x-axis. One cog goes one way, the other is opposite.
Sounds simple, eh? However, it's turning out to be rather difficult to actually achieve. Something is wrong with Spring, I think- the COBHandler code doesn't seem to get an update to Heading01 correctly, or something. Sometimes, it seems to operate correctly... other times, it doesn't even seem to run the cog part of the script until well after it has turned the Turret to the target. What's really irritating is the inconsistency of the way it's operating- first it does one thing, then another, and there doesn't seem to be a clear pattern here.
Anybody got any ideas?
Code: Select all
AimWeapon1(heading, pitch, HeadingNow, Tolerance)
{
signal SIG_AIM1;
set-signal-mask SIG_AIM1;
Heading01 = heading;
Pitch01 = pitch;
if(LastHeading != Heading01)
{
if(Heading01 <= 32768)
{
HeadingNow = Heading01;
}
if(Heading01 > 32768)
{
HeadingNow = 0 - Heading01;
}
if(HeadingNow > LastHeading)
{
Tolerance = HeadingNow - LastHeading;
if (Tolerance > 1)
{
turn cogs_l to x-axis 0 - HeadingNow / 2 speed <120>;
turn cogs_r to x-axis HeadingNow / 2 speed <120>;
}
}
if(HeadingNow < LastHeading)
{
Tolerance = HeadingNow - LastHeading;
if (Tolerance > 1)
{
turn cogs_l to x-axis HeadingNow / 2 speed <120>;
turn cogs_r to x-axis 0 - HeadingNow / 2 speed <120>;
}
}
LastHeading = HeadingNow;
}
turn turret to y-axis Heading01 speed <120>;
turn aimer to x-axis 0 - Pitch01 speed <130>;
wait-for-turn turret around y-axis;
wait-for-turn aimer around x-axis;
start-script RestoreAfterDelay();
return(TRUE);
}