This what I am trying to do. An elevator.

so if the newdeck selected is different than where the elevator close the door, move the elevator and open the new door
where is has issues is the value of edoor2 doesn't increase so the new door doesn't open.
edoor1 does increase til 1.0 then the elev_proc increase to newdeck(.45), but no edoor2

sprintf(oapiDebugString(),"newdeck %2.2f edoor1 %2.2f elev_proc %2.2f edoor2 %2.2f",newdeck,edoor1,elev_proc,edoor2);    
double fDeltaLift1 = LIFT_SPEED* simdt;
double fDeltaLift = LIFT_SPEED* simdt;

if (newdeck != elev_proc)
{
if (.45 == newdeck)
{
//shut cargo door 
     
           edoor1 += fdeltalift1;
            if( edoor1 >1.0 ) 
                edoor1 = 1.0;
  
if (1 == edoor1)
// door shut
// move elevator
     { elev_proc += fDeltaLift;

         
     
         if(elev_proc + fDeltaLift > newdeck)
            elev_proc = newdeck;
   }  
if  (newdeck == elev_proc)        
// elevator moved 
//open door
         {
            edoor2 += fdeltalift1;
            if( edoor2 >1.0 ) 
                edoor2 = 1.0;
      }    
 
} }
SetAnimation(anim_elevd1, edoor1);
SetAnimation(anim_elevd2, edoor2);
SetAnimation(anim_elev1, elev_proc);

You can't reliably test for equality of floats due the the way they are represented in memory. May floats can't be represented exactly. So you can't reliably use the == operator. You might try something like this:

if( (newdeck > .449) && (newdeck <= .450)
{
   // blabla
}
This article has been dead for over six months. Start a new discussion instead.