I find that this script works fine for me, but other players sometimes report that this sliding bookcase stops working completely. Is there any way I can optimize this script to make it work properly for everyone? The script is attached to an activator, and the objects it moves are statics. References persist is checked for all of them, and they're all unique objects.
begin Uvi_Open_bookcase_switch; Like a normal bookcase, but moves when you have the keyshort Movingfloat Timershort toggleSoundShort StartPosShort StartPos2if ( MenuMode == 1 ) returnendifIf ( StartPos == 0 ) Set StartPos to ( "slidingbookcase"->GetPos, z ) Set StartPos2 to ( "in_t_platform_mov01"->GetPos, z )Endifif ( OnActivate == 1 ) if ( player->GetItemCount "key_teluvirith" > 0 ) if ( Moving == 0 ) set Moving to 1 set toggleSound to 0 elseif ( Moving == 2 ) set Moving to 3 set toggleSound to 0 endif else MessageBox "You need the Tel Uvirith Key to activate this switch." return endifendif; Moving states:; 0 At rest in 'set' (covering door) position; 1 Moving from 'set' to 'open'; 2 At rest in 'open' (revealing door) position; 3 Moving from 'open' to 'set'if ( Moving == 0 ) "slidingbookcase"->SetPos, z, StartPos "in_t_platform_mov01"->SetPos, z, StartPos2 returnelseif ( Moving == 2 ) "slidingbookcase"->SetPos, z, -1578 "in_t_platform_mov01"->SetPos, z, -1690 returnelseif ( Moving == 1 ) if ( toggleSound == 0 ) PlaySound "Door Stone Close" set toggleSound to 1 endif "slidingbookcase"->MoveWorld Z, 75 "in_t_platform_mov01"->MoveWorld Z, 75elseif ( Moving == 3 ) if ( toggleSound == 0 ) PlaySound "Door Stone Close" set toggleSound to 1 endif "slidingbookcase"->MoveWorld Z, -75 "in_t_platform_mov01"->MoveWorld Z, -75endifif ( Timer > 3 ) set Timer to 0 if ( Moving == 1 ) set Moving to 2 else set Moving to 0 endif returnendifset Timer to ( Timer + GetSecondsPassed )end