Register button.lsl

From Second Life Wiki
Jump to navigation Jump to search
// Global Variables
integer available = 1;
integer toAllChannel = -255;                    // general channel - linked message

default
{
    state_entry()
    {
        //on a reset or startup this registration button can be used
        available = 1;
        //set color to available
        llSetColor( <0,255,0>, ALL_SIDES);
        llSetTexture( "busy_anim v5_9", ALL_SIDES);
        llSetTextureAnim( ANIM_ON, ALL_SIDES, 5, 5, 24, 1, 10 );
    }

    touch_start(integer total_number)
    {
        if(available)
        {
           available = 0; 
           llMessageLinked(LINK_ALL_OTHERS, toAllChannel, "ActivateRegistration", NULL_KEY);
           //set color to busy
           llSetColor( <255,255,255>, ALL_SIDES);
           llSetTexture( "busy_anim v5_9", ALL_SIDES);
           llSetTextureAnim( ANIM_ON | LOOP , ALL_SIDES, 5, 5, 0, 23, 10 );
           
        }
    }

///////////////////////////////////////////////////////
//  Link Message of default state                    //
///////////////////////////////////////////////////////   
    link_message(integer sender_number, integer number, string message, key id)
    {
        //if link message is on the correct channel
        if(number == toAllChannel)
        {
            if(llSubStringIndex( message, "RegistrationComplete") != -1)
            {
                //set color to unavaliable
                //llSetColor( <255,0,0>, ALL_SIDES);
                //llSetTextureAnim( ANIM_ON | LOOP , ALL_SIDES, 5, 5, 24, 1, 10 );
                llSetTexture( "alpha", ALL_SIDES);
                available = 0;
            }
            if(llSubStringIndex( message, "TestComplete") != -1)
            {
                //set color to unavailable
                //llSetColor( <255,0,0>, ALL_SIDES);
                //llSetTextureAnim( ANIM_ON | LOOP , ALL_SIDES, 5, 5, 24, 1, 10 );
                llSetTexture( "alpha", ALL_SIDES);
                available = 0;
            }
            if(llSubStringIndex( message, "ReportComplete") != -1)
            {
                //set color to available
                llSetColor( <0,255,0>, ALL_SIDES);
                llSetTexture( "busy_anim v5_9", ALL_SIDES);
                llSetTextureAnim( ANIM_ON, ALL_SIDES, 5, 5, 24, 1, 10 );
                available = 1;
            }
            
            if(llSubStringIndex( message, "ActivateReport") != -1)
            {
                //set color to unavailable
                //llSetColor( <255,0,0>, ALL_SIDES);
                //llSetTextureAnim( ANIM_ON | LOOP , ALL_SIDES, 5, 5, 24, 1, 10 );
                llSetTexture( "alpha", ALL_SIDES);
                available = 0;
            }
            if(llSubStringIndex( message, "ActivateTest") != -1)
            {
                //set color to unavailable
                //llSetColor( <255,0,0>, ALL_SIDES);
                //llSetTextureAnim( ANIM_ON | LOOP , ALL_SIDES, 5, 5, 24, 1, 10 );
                llSetTexture( "alpha", ALL_SIDES);
                available = 0;
            }
            
            if( message == "reset" )
            {
              llResetScript();    
            }
            
        }
        
    } //end of link message
    
}