« Return to Thread: second life

Re: second life

by David Simmons-4 :: Rate this Message:

Reply to Author | View in Thread

I have code that works with a libsecondlife. Put the two scripts into an object and wear the object.
listen.lsl
[CODE]
string msg;
string mesg;
key gOwner;
//key talker;
//list talkers;

//listen_to(key talker)
//{
//        integer index = llListFindList( talkers, [talker] );
//    if ( index != -1 )
//        {
//       talkers = llDeleteSubList(talkers, index, index);
//         llMessageLinked(LINK_SET,0,"BYE",talker);
//        }
//    else
//        {
//        talkers = talkers + talker;
//         llMessageLinked(LINK_SET,0,"HI",talker);
//        }
//}


default
{  
    state_entry()  
    {
        gOwner = llGetOwner();
        llListen(0,"",NULL_KEY,"");
    }

    on_rez(integer i)
    {
//        llWhisper(0,"Owner say /chat or touch me");
        llResetScript();
    }
  
//    touch_start(integer num_detected)
//    {
//        listen_to(llDetectedKey(0));
//    }

        listen(integer channel, string name, key id, string msg)
    {
//        if (msg == "/chat")
//        {
//            listen_to(id);
//            return;
//        }
//        if ((msg == "/reset") && (id == gOwner))
//        {
//            llResetScript();
//        }

//        integer index = llListFindList( talkers, [id] );
     if (id != llGetOwner())
        {
            mesg = llToLower(msg);
            llMessageLinked(LINK_SET,0,msg,id);
        }
    }

}
[/CODE]

pandorabot.lsl
[CODE]
key talker;
key requestid;
string botid;
string cust;
string bodyx;
string reply;
string newreply;
integer that_begin;
integer that_end;
integer cust_begin;
integer chat = 0;

string SearchAndReplace(string input, string old, string new)
{
   return llDumpList2String(llParseString2List(input, [old], []), new);
}


default
{
    state_entry()
    {
        cust="";
        botid="b1e9139eee362838";
    }

    on_rez(integer param)
    {
        llResetScript();
    }

    link_message(integer sender_num, integer num, string msg, key id)
    {
        requestid = llHTTPRequest("http://www.pandorabots.com/pandora/talk-xml?botid="+botid+"&input="+llEscapeURL(msg)+"&custid="+cust,[HTTP_METHOD,"POST"],"");
    }
    http_response(key request_id, integer status, list metadata, string body)
    {
        integer i;
        if (request_id == requestid)
        {
            cust_begin=llSubStringIndex(body, "custid=");
            cust=llGetSubString(body, cust_begin+8, cust_begin+23);
            that_begin = llSubStringIndex(body, "<that>");
            that_end = llSubStringIndex(body, "</that>");
            reply = llGetSubString(body, that_begin + 6, that_end - 1);
            newreply = SearchAndReplace(reply, "%20", " ");
            reply = newreply;
            newreply = SearchAndReplace(reply,"&quot;","\"");
            reply = newreply;
            newreply = SearchAndReplace(reply,"&lt;br&gt;","\n");
            reply = newreply;
            newreply = SearchAndReplace(reply, "&gt;", ">");
            reply = newreply;
            newreply = SearchAndReplace(reply, "&lt;", "<");
           
            llInstantMessage(llGetOwner(),"say "+newreply);  //this line tells the libsecondlife bot to say it.

        }
    }


}

[/CODE]

On Feb 1, 2008 4:55 PM, Chuck Fletcher <chuck@...> wrote:
Look into libsecondlife. its .net code. People have created somewhat
autonomous avatars with it.

Chuck

--------------
Chuck Fletcher
646-867-2312
chuck@...

On Feb 1, 2008, at 6:23 PM, Tony <coramo_r@...> wrote:

> Yes, there are several pre-programmed bots on www.slexchange.com
> (personal plug, search for S-Bot or look under Navillus Batra
> listings)
> There is also some open source code that Dedric Mauric has going,
> though
> I do not know the state of it.
>
> But these are through objects. Getting it to talk through your
> avatar is
> different, and I do not know any open source projects or anyone who is
> selling that.
>
> Tony Bundy (aka Anthony Reisman in SL).
>
> fred-fellbach@... wrote:
>> Hello
>> I wish to connect my Avatar in second life with my pandorabot:
>> when somebody says hello ... to my Avatar, my Avatar answers
>> directly by my pandorabot.
>> Is this possible?
>> Thank you very much for your help
>> Fred
>>
> _______________________________________________
> This is the pandorabots-general mailing list
> To Post, reply to pandorabots-general@...
> Unsubscribe and change preferences at http://list.pandorabots.com/mailman/listinfo/pandorabots-general
> Learn netiquette at http://www.dtcc.edu/cs/rfc1855.html
> Learn to read at http://www.literacy.org/
_______________________________________________
This is the pandorabots-general mailing list
To Post, reply to pandorabots-general@...
Unsubscribe and change preferences at http://list.pandorabots.com/mailman/listinfo/pandorabots-general
Learn netiquette at http://www.dtcc.edu/cs/rfc1855.html
Learn to read at http://www.literacy.org/


_______________________________________________
This is the pandorabots-general mailing list
To Post, reply to pandorabots-general@...
Unsubscribe and change preferences at http://list.pandorabots.com/mailman/listinfo/pandorabots-general
Learn netiquette at http://www.dtcc.edu/cs/rfc1855.html
Learn to read at http://www.literacy.org/

 « Return to Thread: second life