Banner by Marianne McCann

Go Back   Second Citizen MK II > The Mainland: Second Life® > Second Life® Depot

Reply
 
Thread Tools Display Modes

Script: Answering Machine
Old 08-08-2009, 01:47 AM   #1
rykerbeck
Nommable. Nom nom. Hee!

rykerbeck's Avatar
 
Join Date: Aug 2009
Location: Zion
Posts: 42
Send a message via Skype™ to rykerbeck
Default Script: Answering Machine

Code:
// Global variables
list message_list;
integer listen_id = -1;  // Lets us turn off listening when we need to
string current_speaker_name = "";  // Who is currently recording a message


readList()
{
    integer i;


    integer count = llGetListLength( message_list );
    llSay( 0, "You have " + (string) count + " messages:" );
    for( i = 0; i < count; i++ )
    {
        llSay( 0, (string)(i+1) + ": " + llList2String(message_list, i) );
    }
}


resetList()
{
    message_list = llDeleteSubList(message_list, 0, llGetListLength(message_list));
    llSay( 0, "Erased all messages.");
}


addMessage( string name, string message )
{
    string full_message = name + " said, '" + message + "'";
    message_list += full_message;
}


default
{
    on_rez( integer start_param )
    {
        // re-initialize
        message_list = llDeleteSubList(message_list, 0, llGetListLength(message_list));
        listen_id = -1;
        current_speaker_name = "";
    }


    // Listen to a single line, spoken by the person who pressed
    // the "Leave Message" button.
    listen( integer channel, string name, key id, string message )
    {
        if( (channel == 0) && (current_speaker_name == name ) )
        {
            addMessage( current_speaker_name, message );
            llListenRemove( listen_id );
            current_speaker_name = "";
            listen_id = -1;
            llSay(0, "Message recorded: " + message );
        }
    }
    
    // Process messages from buttons
    link_message(integer sender_num, integer num, string message, key id)  
    {   
        // Uses a standard button message format:
        // "Button Message, <button name>, key=<user key>, <user name>"
        
        // Convert comma-separated-values into a list
        list msg_list = llCSV2List( message );
        if( llList2String( msg_list, 0) == "Button Message" )
        {
        
            string sender_name = llList2String( msg_list, 1);
            key user_key = llList2Key( msg_list, 2);
            string user_name = llList2String( msg_list, 3);
            
            if( sender_name == "leave_message_btn" )
            {
                current_speaker_name = user_name;
                if( listen_id != -1 )
                {
                    llListenRemove( listen_id );
                }
                
                listen_id = llListen( 0, user_name, "", "" );
                llSay(0, "Leave a one-line message after the beep...BEEP!" );
            }
            else
            if( sender_name == "play_messages_btn" )
            {
                if( user_key == llGetOwner() )
                {
                    readList();
                }
            }
            else
            if( sender_name == "erase_messages_btn" )
            {
                if( user_key == llGetOwner() )
                {
                    resetList();
                }
            }
        }
   }   
}
rykerbeck is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -4. The time now is 08:48 AM.


vBulletin skins developed by: eXtremepixels
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Second Life® and Linden Lab® are trademarks of Linden Research, Inc.
Second Citizen MK II Forums are not affiliated with or sponsored by Linden Research.
© 2009 - 2011 Second Citizen MKII [SC MKII]
| Home | Register | FAQ | Members List | Calendar | Today's Posts | Search | New Posts |