
  
-- Opens door automatically and not closes it when player is away from door
  
 local open = {}
  
  
function astragate_init(e)
  open[e] = 0
 Hide(2)
end
  
       
  
function astragate_main(e)
 

 if GetPlayerDistance(e) < 150 then


 if open[e] == 0 then
  
  
   --door is closed
   StartTimer(e);
  
   if g_Entity[e]['animating'] == 0 then
  
    SetAnimation(0);
    SetAnimationSpeed(e,200)
    PlayAnimation(e);
  
    open[e] = 1
  
      
    LoopSound(e,0);
  
   end
  
  else
  
   if open[e] == 1  then
  
    -- door collision off after seconds
  
    if GetTimer(e)>18000 then
	
  Show(2)
      CollisionOff(2);
	  StopSound(e,0);
  
 end

   
  end
  end
  
    end
  
end
 

