dim3 Forum

Full Version: Airplane script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
shooks Wrote:I edited the post on the top to have the code brackets. SO how do I fix the script problem quickly?

What's the exact error the script gives in the console?

[>] Brian
Chinkeeyong got it, easy as pie. Change all these function names to airplane or whatever they're really called. Wink
Code:
function event(obj,mainEvent,subEvent,id,tick)
switch (mainEvent) {

case DIM3_EVENT_CONSTRUCT:
audiConstruct(obj);
return;

case DIM3_EVENT_SPAWN:
obj.model.animation.start("idle");
return;

case DIM3_EVENT_COLLIDE:
audiCollide(obj,tick);
audiDamage(obj,tick);
return;

case DIM3_EVENT_TOUCH:
audiCollide(obj,tick);
return;

case DIM3_EVENT_ANIMATION_OBJECT:
audiAnimation(obj,subEvent);
return;

case DIM3_EVENT_LIQUID:
audiLiquid(obj);
return;

case DIM3_EVENT_VEHICLE:
audiEnterOrExit(obj,subEvent);
return;

case DIM3_EVENT_WEAPON_FIRE:
audiCarHorn(obj,subEvent);
return;

case DIM3_EVENT_TIMER:
audiTimer(obj);
return;
}
}
This is a photo of what it says and looks like. I changed all the audi things

[Image: picture6sz5.th.png]
[Image: picture7yd4.th.png]
Did you change the name of the script?
In the last pic, the error message pops up because the engine cant find the correct script.
Check the script spot settings again.
script spot settings? And no I didn't change the scripts
The engine cannot find the script specified in the spot settings (double click the spot and they pop up).
That's a fact. Why that happens, I cannot tell you, since I don't have your map or data folder.
but it detected my changes. When I changed the script more errors ocurred in turn to what I changed. and double click on what
Look, your calling functions that don't exist. Doing that will cause an error. I can't help you more without the script. Wink
[EDIT]So? More errors occurred, so what? Maybe you fixed something and now function is called that has errors in it. Can I see your current version of the script?
btw, Bink means that one of the spots in your map is calling a script that doesn't exist.
Code:
var lastCrashTick;

var lastAngleY;

var smokeCount;

var damageLevel;

var lastDamageTick;



function airplaneConstruct(obj)

{

    obj.model.on=true;

    obj.model.name='airplane';

    obj.model.lit=DIM3_MODEL_LIT_VERTEX;



    obj.model.shadow.on=true;

    obj.model.shadow.alwaysInAir=true;        // force shadow to always be under plane



    obj.setting.damage=true;
    obj.setting.fly=true

    obj.setting.invincible=false;

    obj.setting.turnOnlyWhenMoving=true;

    obj.setting.restrictPlayerTurning=true;

    obj.setting.quickReverse=false;

    obj.setting.sideStep=false;

    obj.setting.jump=false;

    obj.setting.duck=false;

    obj.setting.singleSpeed=true;

    obj.setting.bumpUp=true;



    obj.size.x=2800;

    obj.size.z=5600;

    obj.size.y=1900;

    obj.size.weight=2000;

    

    obj.rigidBody.on=true;



    obj.vehicle.on=true;

    

    obj.turnSpeed.facingWalk=1.5;

    obj.turnSpeed.motionWalk=0.6;

    obj.turnSpeed.facingAir=3;

    obj.turnSpeed.motionAir=3;

    

    obj.forwardSpeed.walk=250;

    obj.forwardSpeed.acceleration=0.5;

    obj.forwardSpeed.deceleration=1.75;

    obj.forwardSpeed.accelerationAir=0.4;

    obj.forwardSpeed.decelerationAir=0.6;

    

    obj.objectSpeed.bounceFactor=1.3;        // this makes the audi bounce off when hitting things

    obj.objectSpeed.bumpHeight=500;

    

    obj.look.upAngle=5;

    obj.look.downAngle=10;

    obj.health.maximum=200;
    obj.health.start=200;

    

        // headlight

        

    obj.model.light.on=true;

    obj.model.light.type=DIM3_LIGHT_TYPE_NORMAL;

    obj.model.light.intensity=16000;

    

    obj.model.lightColor.red=1;

    obj.model.lightColor.green=1;

    obj.model.lightColor.blue=0.8;



        // the car engine ambient

            

    obj.setting.setAmbient('Car Engine',1);

    

    lastCrashTick=0;

    lastAngleY=0;

    smokeCount=0;

    damageLevel=0;

    lastDamageTick=0;

}



//

// car animations

//



function airplaneAnimation(obj,subEvent)

{

    var            model;

    

    model=obj.model;

    

    switch (subEvent) {

    

        case DIM3_EVENT_ANIMATION_OBJECT_STOP:

            model.animation.change('Idle');

            return;



        case DIM3_EVENT_ANIMATION_OBJECT_WALK:

            model.animation.change('fly');

            return;

            

        case DIM3_EVENT_ANIMATION_OBJECT_WALK_BACK:

            model.animation.change('fly');

            return;



    }

}

//
// car in liquids
//

function airplaneLiquid(obj)

{

    sound.play("Splash",obj.position.x,obj.position.z,obj.position.y,1);

}



//

// car timer

//



function airplaneTimer(obj)

{

    var        speed,pitch,smoke,pnt;

    

        // engine sound

    

    speed=obj.status.speed;

    pitch=1.0;

    

    if (speed<20) {

        pitch=1.0;

    }

    else {

        if (speed>=150) {

            pitch=1.5;

        }

        else {

            pitch=1+(0.5*((speed-20)/130));

        }

    }

    

    obj.setting.changeAmbientPitch(pitch);

    

        // time to start smoking?

      

    if (speed!=0) {

        if (utility.angle.dif(obj.angle.y,lastAngleY)>12) smokeCount=5;

    }

    if ((speed>0) && (speed<100)) smokeCount=10;

    

    lastAngleY=obj.angle.y;

    

        // smoke

        

    if (smokeCount!=0) {

        smokeCount--;

        

        pnt=obj.model.bone.findPosition(null,'BOdy');

        spawn.particle(pnt.x,pnt.z,pnt.y,'Car Smoke');

        pnt=obj.model.bone.findPosition(null,'BOdy');

        spawn.particle(pnt.x,pnt.z,pnt.y,'Car Smoke');

    }

}



//

// entering and exiting auti

//



function airplaneEnter(obj)

{

        // backup the original camera

        

    camera.state.save();

        

        // change camera for airplane

        

    camera.setting.type=DIM3_CAMERA_TYPE_CHASE;

    

    camera.chase.distance=10500;

    camera.chase.trackSpeed=0.1;

    

    camera.chaseAngle.x=-100;

    camera.chaseAngle.y=100;

    camera.chaseAngle.z=50;

        

    camera.chaseSlop.y=25;

    

        // start a timer for engine noise

        

    obj.event.startTimer(1,0);

}



function airplaneExit(obj)

{

        // turn off the engine noise timer

        

    obj.event.clearTimer();

    

        // restore camera

        

    camera.state.restore();

    

        // make sure animation is idling

        

    obj.model.animation.change('Running');

}



function airplaneEnterOrExit(obj,subEvent)

{

        // door sound

        

//    sound.play("Car Door",obj.position.x,obj.position.z,obj.position.y,1);



        // start or stop changes

        

    switch (subEvent) {

    

        case DIM3_EVENT_VEHICLE_ENTER:

            airplaneEnter(obj);

            break;

            

        case DIM3_EVENT_VEHICLE_EXIT:

            airplaneExit(obj);

            break;

            

    }

}



//

// car colliding with map or object

//



function airplaneCollide(obj,tick)

{

        // if car isn't moving, then no collide effects



    if (!obj.status.moving) return;



        // car hit sound



    if (tick>lastCrashTick) {

        sound.play("Crash",obj.position.x,obj.position.z,obj.position.y,0.7);

        lastCrashTick=tick+800;

    }



        // turn on the smoke

        

    smokeCount=20;

}



//

// car taking damage when colliding with wall

//



function airplaneDamage(obj,tick)

{



        // max damage level is 2



    if (damageLevel==2) return;



        // only take damage at certain rates



    if (tick<lastDamageTick) return;



    lastDamageTick=tick+2000;



        // change for damage



    damageLevel++;



    switch (damageLevel) {



        case 1:        // break window

            obj.model.fill.change(1,1);

            break;

        case 2:        // damage body

            obj.model.fill.change(0,1);

            break;



    }

}



//

// car horn

//



function audiCarHorn(obj,subEvent)

{

        // if no weapon selected, then all fire messages come directly to object

        // only check for fire message

    

    if (subEvent==DIM3_EVENT_WEAPON_FIRE_DOWN) sound.play("Car Horn",obj.position.x,obj.position.z,obj.position.y,1);

}



//

// events

//



function event(obj,mainEvent,subEvent,id,tick)

{

    switch (mainEvent) {

    

        case DIM3_EVENT_CONSTRUCT:

            airplaneConstruct(obj);

            return;

    

        case DIM3_EVENT_SPAWN:

            obj.model.animation.start("Idle");

            return;

            

        case DIM3_EVENT_COLLIDE:

            airplaneCollide(obj,tick);

            airplaneDamage(obj,tick);

            return;



        case DIM3_EVENT_TOUCH:

            airplaneCollide(obj,tick);

            return;

            

        case DIM3_EVENT_ANIMATION_OBJECT:

            airplaneAnimation(obj,subEvent);

            return;
            

        case DIM3_EVENT_LIQUID:

            airplaneLiquid(obj);

            return;



        case DIM3_EVENT_VEHICLE:

            airplaneEnterOrExit(obj,subEvent);

            return;

            

        case DIM3_EVENT_WEAPON_FIRE:

            airplaneCarHorn(obj,subEvent);

            return;

            

        case DIM3_EVENT_TIMER:

            airplaneTimer(obj);

            return;



    }

}

now the only error is it's not taking off. and that it can't locate a script sa mentioned b4.
Change audiHorn to airplaneHorn or something. Wink
lol airplane with a horn. :P

btw try setting the weight to 0 to make it take off.
Pages: 1 2 3
Reference URL's