const int ringTimePerMP = 15; //How many frames 1 unit of MP lasts with the One Ring

global script active{
    void run(){
        bool ringOn;
        int ringTimer;
        
        while(true){
            if ( ringOn && Link->MP ){                
                //Decrement magic
                ringTimer = (ringTimer+1) % ringTimePerMP;
                if ( !ringTimer ) Link->MP--;
                
                if ( Link->MP <= 0 //If magic ran out
                || Link->Action == LA_SCROLLING //Or left screen
                ){ //Take off ring
                    ringOn = false;
                    Link->CollDetection = true;
                    Link->Invisible = false;
                }

            }
            else if ( !ringOn ){ //Disable ring
                Link->CollDetection = true;
                Link->Invisible = false;
            }
        }
    }
}

item script theOneRing{
    void run(int onSFX, int offSFX){
        if ( !ringOn && Link->MP > 0 ){
            ringOn = true
            Game->PlaySound(onSFX);
            
            Link->CollDetection = false;
            Link->Invisible = true;
        }
        else if ( ringOn ){
            ringOn = false;
            Game->PlaySound(offSFX);
        }
    }
}