SL Chat Logger

From SimTeach

Jump to: navigation, search

Place the script in an object. Records chat and plays it back when touched by the owner.

This chat logger has been designed to add color-codes to chat for posting on the official SL forums. With very minor changes, it would add colours in HTML format.

Be aware that recording chat without express permission is against the SL terms of service. Alternative chat-loggers are available in Second Life which only record chat once permission has been given through replying to a dialog. beijing massage shanghai massage


list names;
list speech;
list colours=["002EB8","FF6633","006600","660066","660033","663300","1A9900","FF14B1","001A99","B88A00"];
list unique_names;

default
{
    state_entry()
    {
        llSetText("This is a chat logger - currently only for testing",<0,0,0>,1.0);
        integer i;
        integer c;
        for (i=0;i<llGetListLength(names);i++)
        {
            c = llListFindList(unique_names,llList2List(names,i,i)  );
            while (c >= llGetListLength(colours)) // dont crash if I run out of colours
                c -= llGetListLength(colours);
            llSetObjectName("[color=#" + llList2String(colours,c)
                + "]" + llList2String(names,i) );
            llOwnerSay( llList2String(speech,i) + "[/color]" );
        }
        names = [];
        speech = [];
        unique_names = [];
        llSetObjectName("Patch's Funky Chat Logger");
    }

    on_rez(integer i)
    {
        llResetScript();
    }
    
    touch_start(integer total_number)
    {
        if (llDetectedKey(0) == llGetOwner() )
        {
            llSay(0, "logging on!.");
            state logging_chat;
        }
    }
}

state logging_chat
{
    state_entry()
    {
        llListen(0,"",NULL_KEY,"");
    }

    on_rez(integer i)
    {
        llOwnerSay("Logging still on! Touch to get playback");
    }
    
    touch_start(integer total_number)
    {
        if (llDetectedKey(0) == llGetOwner() )
        {
            llSay(0, "chat logging now off - replaying log!.");
            state default;
        }
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if(llListFindList(unique_names,[name]) == -1)
        {
            unique_names += name;
        }
        names += name;
        speech += message;
    }

} 
Personal tools