Author Topic: Onadd spam  (Read 775 times)

For hover vehicles, there seems to be an onadd problem
Code: [Select]
Add-Ons/Vehicle_Something/Vehicle_Something.cs (179): Unknown command onAdd.
Code: [Select]
function Somethingvehicle::onadd(%this,%obj)
{

parent::onadd(%this,%obj);

contrailCheck(%obj);
   
}
It does the check, but it spams the console with the above.

The hover vehicle type isn't supported at all. It wouldn't have a parent function written and won't work properly anyway.

The hover vehicle type isn't supported at all. It wouldn't have a parent function written and won't work properly anyway.
Is this fixable with engine changes? This sucks since most helicopters are hover vehicles and most need an onadd to play the rotation.

Remove the parent::onadd.

Code: [Select]
datablock ParticleData(ContrailParticle)
{
   dragCoefficient      = 0;
   windCoefficient     = 0;
   gravityCoefficient   = 0;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   spinRandomMin = -90;
   spinRandomMax = 90;
   lifetimeMS           = 500;
   lifetimeVarianceMS   = 0;
   textureName          = "base/data/particles/cloud";
   colors[0]     = "1 1 1 1";
   colors[1]     = "0.2 0.2 1 0";
   sizes[0]      = 0.1;
   sizes[1]      = 0.05;
};

datablock ParticleEmitterData(ContrailEmitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 0;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "ContrailParticle";
};

datablock ShapeBaseImageData(ContrailImage1)
{
   shapeFile = "base/data/shapes/empty.dts";
emap = false;

mountPoint = 11;
   rotation = "1 0 0 -90";

stateName[0] = "Ready";
stateTransitionOnTimeout[0] = "FireA";
stateTimeoutValue[0] = 0.01;

stateName[1] = "FireA";
stateTransitionOnTimeout[1] = "Done";
stateWaitForTimeout[1] = True;
stateTimeoutValue[1] = 10000;
stateEmitter[1] = ContrailEmitter;
stateEmitterTime[1] = 10000;

stateName[2] = "Done";
stateScript[2] = "onDone";
};
function ContrailImage1::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}
datablock ShapeBaseImageData(ContrailImage2)
{
    shapeFile = "base/data/shapes/empty.dts";
emap = false;

mountPoint = 12;
    rotation = "1 0 0 -90";

stateName[0] = "Ready";
stateTransitionOnTimeout[0] = "FireA";
stateTimeoutValue[0] = 0.01;

stateName[1] = "FireA";
stateTransitionOnTimeout[1] = "Done";
stateWaitForTimeout[1] = True;
stateTimeoutValue[1] = 10000;
stateEmitter[1] = ContrailEmitter;
stateEmitterTime[1] = 10000;

stateName[2] = "Done";
stateScript[2] = "onDone";
};
function ContrailImage2::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}

function ContrailCheck(%obj)
{
// return;
if(!isObject(%obj))
return;

%speed = vectorLen(%obj.getVelocity());
if(%speed < %obj.dataBlock.minContrailSpeed)
{
if(%obj.getMountedImage(11) !$= "")
{
%obj.unMountImage(11);
%obj.unMountImage(12);
}
}
else
{
if(%obj.getMountedImage(11) $= 0)
{
%obj.mountImage(ContrailImage1,11);
%obj.mountImage(ContrailImage2,12);
}
}



schedule(2000,0,"ContrailCheck",%obj);
}
This doesn't seem to work. When I change the mounts on the image to 3 and 4, it mounts to 3 and 4. It doesn't seem to want to mount to anything else though.

You're using the same particles and uiNames as the Stunt Plane's contrail.

Use a FlyingVehicle instead of a HoverVehicle - see the Magic Carpet for how to make one hover.

You're using the same particles and uiNames as the Stunt Plane's contrail.

Use a FlyingVehicle instead of a HoverVehicle - see the Magic Carpet for how to make one hover.
I edited it into a flying vehicle and it still didn't work.

It seems to only want to work with 2 mountpoints
Code: [Select]
datablock ParticleData(contrailParticle)
{
   dragCoefficient      = 0;
   windCoefficient     = 0;
   gravityCoefficient   = 0;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   spinRandomMin = -90;
   spinRandomMax = 90;
   lifetimeMS           = 500;
   lifetimeVarianceMS   = 0;
   textureName          = "base/data/particles/cloud";
   colors[0]     = "1 1 1 1";
   colors[1]     = "0.2 0.2 1 0";
   sizes[0]      = 0.1;
   sizes[1]      = 0.05;
};

datablock ParticleEmitterData(contrailEmitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 0;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "contrailParticle";
};

datablock ShapeBaseImageData(ContrailImage1)
{
   shapeFile = "base/data/shapes/empty.dts";
emap = false;

mountPoint = 4;
   rotation = "1 0 0 -90";

stateName[0] = "Ready";
stateTransitionOnTimeout[0] = "FireA";
stateTimeoutValue[0] = 0.01;

stateName[1] = "FireA";
stateTransitionOnTimeout[1] = "Done";
stateWaitForTimeout[1] = True;
stateTimeoutValue[1] = 10000;
stateEmitter[1] = ContrailEmitter;
stateEmitterTime[1] = 10000;

stateName[2] = "Done";
stateScript[2] = "onDone";
};
function ContrailImage1::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}
datablock ShapeBaseImageData(ContrailImage2)
{
    shapeFile = "base/data/shapes/empty.dts";
emap = false;

mountPoint = 5;
    rotation = "1 0 0 -90";

stateName[0] = "Ready";
stateTransitionOnTimeout[0] = "FireA";
stateTimeoutValue[0] = 0.01;

stateName[1] = "FireA";
stateTransitionOnTimeout[1] = "Done";
stateWaitForTimeout[1] = True;
stateTimeoutValue[1] = 10000;
stateEmitter[1] = ContrailEmitter;
stateEmitterTime[1] = 10000;

stateName[2] = "Done";
stateScript[2] = "onDone";
};
function ContrailImage2::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}

function contrailCheck(%obj)
{
// return;
if(!isObject(%obj))
return;

%speed = vectorLen(%obj.getVelocity());
if(%speed < %obj.dataBlock.minContrailSpeed)
{
if(%obj.getMountedImage(4) !$= "")
{
%obj.unMountImage(4);
%obj.unMountImage(5);
echo("nothing");
}
}
else
{
if(%obj.getMountedImage(4) $= 0)
{
%obj.mountImage(contrailImage1,4);
%obj.mountImage(contrailImage2,5);
echo("something");
}
}

if(%speed < 5)
{
if(%obj.prop !$= "slow")
{
%obj.playThread(0,propslow);
%obj.prop = "slow";
}
}
else
{
if(%obj.prop !$= "fast")
{
%obj.playThread(0,propfast);
%obj.prop = "fast";
}
}

schedule(2000,0,"contrailCheck",%obj);
}
It only works with this.
Code: [Select]
datablock ParticleData(contrailParticle)
{
   dragCoefficient      = 0;
   windCoefficient     = 0;
   gravityCoefficient   = 0;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   spinRandomMin = -90;
   spinRandomMax = 90;
   lifetimeMS           = 500;
   lifetimeVarianceMS   = 0;
   textureName          = "base/data/particles/cloud";
   colors[0]     = "1 1 1 1";
   colors[1]     = "0.2 0.2 1 0";
   sizes[0]      = 0.1;
   sizes[1]      = 0.05;
};

datablock ParticleEmitterData(contrailEmitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 0;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "contrailParticle";
};

datablock ShapeBaseImageData(ContrailImage1)
{
   shapeFile = "base/data/shapes/empty.dts";
emap = false;

mountPoint = 3;
   rotation = "1 0 0 -90";

stateName[0] = "Ready";
stateTransitionOnTimeout[0] = "FireA";
stateTimeoutValue[0] = 0.01;

stateName[1] = "FireA";
stateTransitionOnTimeout[1] = "Done";
stateWaitForTimeout[1] = True;
stateTimeoutValue[1] = 10000;
stateEmitter[1] = ContrailEmitter;
stateEmitterTime[1] = 10000;

stateName[2] = "Done";
stateScript[2] = "onDone";
};
function ContrailImage1::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}
datablock ShapeBaseImageData(ContrailImage2)
{
    shapeFile = "base/data/shapes/empty.dts";
emap = false;

mountPoint = 4;
    rotation = "1 0 0 -90";

stateName[0] = "Ready";
stateTransitionOnTimeout[0] = "FireA";
stateTimeoutValue[0] = 0.01;

stateName[1] = "FireA";
stateTransitionOnTimeout[1] = "Done";
stateWaitForTimeout[1] = True;
stateTimeoutValue[1] = 10000;
stateEmitter[1] = ContrailEmitter;
stateEmitterTime[1] = 10000;

stateName[2] = "Done";
stateScript[2] = "onDone";
};
function ContrailImage2::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}

function contrailCheck(%obj)
{
// return;
if(!isObject(%obj))
return;

%speed = vectorLen(%obj.getVelocity());
if(%speed < %obj.dataBlock.minContrailSpeed)
{
if(%obj.getMountedImage(3) !$= "")
{
%obj.unMountImage(2);
%obj.unMountImage(3);
}
}
else
{
if(%obj.getMountedImage(3) $= 0)
{
%obj.mountImage(contrailImage1,2);
%obj.mountImage(contrailImage2,3);
}
}

if(%speed < 5)
{
if(%obj.prop !$= "slow")
{
%obj.playThread(0,propslow);
%obj.prop = "slow";
}
}
else
{
if(%obj.prop !$= "fast")
{
%obj.playThread(0,propfast);
%obj.prop = "fast";
}
}

schedule(2000,0,"contrailCheck",%obj);
}
Both are exactly the same except for the mount points. Yes, the stunt plane was disabled when I tried this. I don't want to change names until I am sure the problem of mounting is fixed.