-->

FoxSan's 3D Tools and LSL Script Repository

Tons of LSL scripts, examples and 3D tools, free for all. There are currently 207 scripts and articles in this database.

#LSL<->Client Bridge v0.06

integer channel(key id)
{
    //llOwnerSay(llMD5String((string)id,1));
    return (integer)("0x"+llGetSubString(llMD5String((string)id,1),0,6));
}
integer recieve_channel;// = channel(key id)
integer tid;
integer altListenHandler;
integer listenReq;
integer startTime;
vector  moveToTarget;
 
integer tid2;
integer l2c;
connect()
{
    llListenRemove(tid);
    tid = llListen(recieve_channel,"",llGetOwner(),"");
    if(l2c != 0)
    {
        llListenRemove(tid2);
        tid2 = llListen(l2c,"",llGetOwner(),"");
    }
    if(llGetAttached() != 0)llRequestPermissions(llGetOwner(),PERMISSION_TRACK_CAMERA | PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
}
send(string data)
{
  //if(llStringLength(data) > (1023 - 5))llOwnerSay("ERR: string too long");
    llOwnerSay("#@#@#"+data);
  //llOwnerSay("Sending"+data);
}
 
integer max_rand_integer()
{
    return (integer)(((llFrand(0.999998) + 0.000001) + ((llFrand(0.899) + 0.1) * 1000)) * 1000000);
}
recieve(string data)
{
    list instruction = llParseString2List(data,["|"],[]);
    integer id = (integer)llList2String(instruction,0);
    string cmd = llList2String(instruction,1);
    if(cmd == "online_status")
    {
        onlinereqs += [id, llRequestAgentData((key)llList2String(instruction,2), DATA_ONLINE)];
        //llOwnerSay("processing online request");
    }if(cmd == "http_req")
    {
        list m;
        if(llList2String(instruction,3) == "POST")m = [HTTP_METHOD, "POST"];
        httpreqs += [id, llHTTPRequest(llList2String(instruction,2),m,llList2String(instruction,4))];
        //llOwnerSay("processing online request");
    }else if(cmd == "pos")
    {
        list positions = [id];
        integer inc = 2;
        for(;inc<(instruction!=[]);inc++)
        {
            //send in the same order we recieved.
            positions += [(string)llGetObjectDetails((key)llList2String(instruction,inc),[OBJECT_POS])];
        }
        send(llDumpList2String(positions,"|"));
    }else if(cmd == "listen")//for client listening on channels, 0 to stop
    {
        listenReq = id;
        llListenRemove(altListenHandler);
        integer channelToListenOn = (integer)llList2String(instruction,2);
        if(channelToListenOn)
            altListenHandler = llListen(channelToListenOn,"",NULL_KEY,"");
    }else if (cmd == "move")//for client to use llmovetotarget
    {
        moveToTarget=(vector)llList2String(instruction,2);
        startTime=llGetUnixTime();
        llSetTimerEvent(.05);
    }else if(cmd == "l2c")
    {
        l2c = max_rand_integer();
        connect();
        llOwnerSay("l2c"+(string)l2c);
    }
}
 
list onlinereqs;
list httpreqs;
default
{
    state_entry()
    {
        recieve_channel = channel(llGetOwner());
        //llOwnerSay((string) recieve_channel);
        connect();
    }
 
    listen(integer channel, string name, key id, string message)
    {
        if(channel == recieve_channel || channel == l2c)
        {
            recieve(message);
            return;
        }
        send(llDumpList2String([listenReq,channel,name,id,message],"|"));
    }
 
    run_time_permissions(integer p)
    {
        if(p)llTakeControls(1024,1,1);
    }
 
    dataserver(key id, string data)
    {
        integer i = llListFindList(onlinereqs,[id]);
        if(i != -1)
        {
            //llOwnerSay("returning online request");
            send((string)llList2Integer(onlinereqs,i-1)+"|"+data);
            onlinereqs = llDeleteSubList(onlinereqs,i-1,i);
        }
    }
 
    http_response(key id, integer status, list meta, string body)
    {
        integer i= llListFindList(httpreqs,[id]);
        if(i != -1)
        {
            send((string)llList2Integer(httpreqs,i-1)+"|"+(string)status+"|"+llList2CSV(meta)+"|"+body);
            httpreqs = llDeleteSubList(httpreqs,i-1,i);
        }
    }
 
    timer()
    {
        llSetTimerEvent(0.0);
        if(llGetUnixTime() - 10 > startTime){llStopMoveToTarget();return;}
        vector us = llGetPos();
        vector dist = moveToTarget - us;
        float mag = llVecMag(dist);
        if(mag < 1.0){llStopMoveToTarget();return;}
        if(mag>45) llMoveToTarget(us+llVecNorm(dist)*45,.05);
        else llMoveToTarget(moveToTarget,.05);
        llSetTimerEvent(.05);
    }
}

5 Responses to “#LSL<->Client Bridge v0.06”


  1. Kazue Eglerion

    Deletei sem querer meu Lsl se vc puder me repor o mais rapido possivel eu agradeco!

  2. Hi Kazue, I have translated this as “I deleted accidentally my LSL if you can restore me as fast as possible I thank you!”. Could you please exactly describe what the problem is? Thank you :)


  3. Kazue Eglerion

    eu deletei acidentalmente o cliente lsl bridge do emerald. quando entro fico off.
    tem como recuperar???

  4. Hi Kazue, in reply your question “I deleted accidentally the client lsl bridge emerald. whenever I’m off. is to recover??” this is the following answer: Go to Preferences > Emerald > Misc > Click “Enable LSL-Client Bridge” and click OK. I hope this helps. :) (Google Translates: Oi Kazue, em resposta à sua pergunta, esta é a resposta seguinte: Vá para Preferências> Emerald> Misc> Clique em “Enable LSL-Client Bridge” e clique em OK. Espero que isso ajude. :) “

  5. Too bad the Emerald Project is gone now. :)

Leave a Reply