Category:Scripts: Difference between revisions

From OpenSimulator
Jump to navigationJump to search
imported>Fly-man-
imported>Pato Donald
No edit summary
Line 1: Line 1:
Hi all.
Hi all. As this page is still here i guess it's either been overlooked or it may be useful. I'll continue to put scripts that I've found that work.. It will i hope be obvious that they are not mine, and that i am not nor claim to be the author.  
As this page is still here i guess it's either been overlooked or it may be useful.
I'll continue to put scripts that I've found that work..
It will i hope be obvious that they are not mine, and that i am not nor claim to be the author.


The scripts are gleemed from anywhere open source, and my thanks go out to all
The scripts are gleemed from anywhere open source, and my thanks go out to all those bright people who write this stuff :-)  
those bright people who write this stuff :-)


I am running opensim from the svn (Latest build daily) thing, then compile it in visual studio
I am running opensim from the svn (Latest build daily) thing, then compile it in visual studio it occasionally wants to update the code to 2008 vers so i let it :-) where possible i will show the author and a link :-) Any problems let me know zoon@edenrealm.co.uk copy all below the "heading" into a new script in your in-world inventory, then drag and drop into your prim..... as if you didnt know :-) Samantha can be located on Openlife grid, Oh yes, i have played with the settings a little. There are lots of sources to look at and OsGrid would be a great place to start.  
it occasionally wants to update the code to 2008 vers so i let it :-)
where possible i will show the author and a link :-)
Any problems let me know zoon@edenrealm.co.uk
copy all below the "heading" into a new script in your in-world inventory, then drag and drop into your prim.....
as if you didnt know :-) Samantha can be located on Openlife grid, Oh yes, i have played with the settings a little.
There are lots of sources to look at and OsGrid would be a great place to start.


== Particles ==
== Particles ==


<source lang="lsl">
<source lang="lsl">
Line 82: Line 72:
     }
     }
}
}
</source>
</source>  


== Sound loop ==
== Sound loop ==


<source lang="lsl">
<source lang="lsl">
Line 101: Line 91:
     }
     }
}
}
</source>
</source>  


== Smooth rotate texture ==
== Smooth rotate texture ==


<source lang="lsl">
<source lang="lsl">
Line 116: Line 106:
}
}


</source>
</source>  
 
== Sit and position  ==


== Sit and position ==
Just drop into an object and play with the vector rot stuff and llsitTarget till happy&nbsp;:-)  
Just drop into an object and play with the vector rot stuff and llsitTarget till happy :-)


<source lang="lsl">
<source lang="lsl">
Line 135: Line 126:
}
}


</source>
</source>  


== Rotating Prim ==
== Rotating Prim ==


I think this came from Nebaden :-).....
I think this came from Nebaden&nbsp;:-).....  


<source lang="lsl">
<source lang="lsl">
Line 152: Line 143:
   }
   }


</source>
== A Opensim version for llHTTPResponse ==
As we know, until now we receive a very nice message for llHTTPResponse :D, but to make a prim communicate to another, i've made this method:
'''Client'''
<source>
// This script is to do a request on the primitive url on the description and return it's response.
key url_request;
string myurl; //This is only valid for internal Requests/Responses, for calling from other grids, use the simulator ip:port where it shows something like 2K3S-***-***-***:port, but mantain the rest.
integer listen_u;
string prepare_post_body(list l)
{
    integer i;
    string body;
    integer len=llGetListLength(l) & 0xFFFE; // make it even
    for (i=0;i<len;i+=2)
    {
        string varname=llList2String(l,i);
        string varvalue=llList2String(l,i + 1);
        if (i>0) body+="&";
        body+=llEscapeURL(varname)+"="+llEscapeURL(varvalue);
    }
    return body;
}
list Postdata2List(string data)
{
    return llParseString2List(data, "&", "");
}
string Httpdata2String(string data)
{
    list d = llParseString2List(data, "=", "");
    return llUnescapeURL(llList2String(d, 1));
}
key FastHttpRequest(string url, list meta, list body)
{
    return llHTTPRequest(url, meta, prepare_post_body(body));
}
default
{
   
    state_entry()
    {
        url_request = llRequestURL();
    }
    http_request(key id, string method, string body)
    {
        if (url_request == id)
        {
            url_request = "";
            if (method == "URL_REQUEST_GRANTED")
            {
                llSetText("MyURL> " + body, <1,.5,0>, 1.0);
                myurl = body;
                state run;
            }
            else if (method == "URL_REQUEST_DENIED")
            {
                llSay(0, "Something went wrong, no url. " + body);
            }
        }
        else
        {
            llSay(0, "Received> " + body);
        }
    }
}
state run
{
    state_entry()
    {
        llSay(0, "Running, touch for request to my description.");
        listen_u = llListen(-1, "", "", "");
        llListen(1, "", "", "reset");
    }
   
    listen(integer c, string n, key k, string m)
    {
        if(c == -1)
        {
            llListenRemove(listen_u);
            llSetObjectDesc(m);
        }
        if(c == 1 && m == "reset")
        {
            llResetScript();
        }
    }
   
    touch_start(integer i)
    {
        FastHttpRequest(llGetObjectDesc(), [HTTP_METHOD, "POST",HTTP_MIMETYPE, "application/x-www-form-urlencoded"],["MYURL",myurl,"MESSAGE","Hello, my name is " + llGetObjectName() + "."]);
    }
    http_request(key id, string method, string body)
    {
        if (url_request == id)
        {
            url_request = "";
            if (method == "URL_REQUEST_GRANTED")
            {
                llSetText("MyURL> " + body, <1,.5,0>, 1.0);
                myurl = body;
            }
            else if (method == "URL_REQUEST_DENIED")
            {
                llSay(0, "Something went wrong, no url. " + body);
            }
        }
        else
        {
            list body_i = Postdata2List(body);
            string url = Httpdata2String(llList2String(body_i,0));
            string data = Httpdata2String(llList2String(body_i,1));
            llSay(0, "Received> " + data);
        }
    }
}
</source>
'''Server'''
<source>
key url_request;
string myurl;//This is only valid for internal Requests/Responses, for calling from other grids, use the simulator ip:port where it shows something like 2K3S-***-***-***:port, but mantain the rest.
string prepare_post_body(list l)
{
    integer i;
    string body;
    integer len=llGetListLength(l) & 0xFFFE; // make it even
    for (i=0;i<len;i+=2)
    {
        string varname=llList2String(l,i);
        string varvalue=llList2String(l,i + 1);
        if (i>0) body+="&";
        body+=llEscapeURL(varname)+"="+llEscapeURL(varvalue);
    }
    return body;
}
list Postdata2List(string data)
{
    return llParseString2List(data, "&", "");
}
string Httpdata2String(string data)
{
    list d = llParseString2List(data, "=", "");
    return llUnescapeURL(llList2String(d, 1));
}
key FastHttpRequest(string url, list meta, list body)
{
    return llHTTPRequest(url, meta, prepare_post_body(body));
}
default
{
    state_entry()
    {
        url_request = llRequestURL();
    }
    touch_start(integer i)
    {
//        llSay(0, "URL: " + myurl);
//       
//        llSay(-1, myurl);
       
        llSetText(" ", <0,0,0>, 0.0);
       
        llResetScript();
    }
    http_request(key id, string method, string body)
    {
        if (url_request == id)
        {
            url_request = "";
            if (method == "URL_REQUEST_GRANTED")
            {
                llSay(0,"New URL: " + body);
               
                llSay(-1, body);
                myurl = body;
            }
            else if (method == "URL_REQUEST_DENIED")
            {
                llSay(0, "Something went wrong, no url. " + body);
            }
        }
        else
        {
//            llSay(0, body);
            list body_i = Postdata2List(body);
            string url = Httpdata2String(llList2String(body_i,0));
            string data = Httpdata2String(llList2String(body_i,1));
            llSetText("FROM: " + url + "\nDATA: " + data, <1,.5,0>, 1.0);
//            llSay(0, "FROM: " + url + "\nDATA: " + data);
//            llHTTPResponse(id, 200, body);
            llSay(0, "Response to " + url);
            FastHttpRequest(url, [HTTP_METHOD, "POST",HTTP_MIMETYPE, "application/x-www-form-urlencoded"], ["MYURL", myurl, "MESSAGE", "You sent me: \""+data+"\""]);
            llSay(0, "Sent!");
        }
    }
}
</source>
</source>
'''To receive a response, you need to send in the body this parameter: ''MYURL'' and in value add the object url, but if you need, try to change the value of url to the ip:port of region, sometimes it may be strange.'''
Is it, easy? ;D


Will keep updating until told otherwise :-)
Will keep updating until told otherwise&nbsp;:-)

Revision as of 19:28, 10 December 2009

Hi all. As this page is still here i guess it's either been overlooked or it may be useful. I'll continue to put scripts that I've found that work.. It will i hope be obvious that they are not mine, and that i am not nor claim to be the author.

The scripts are gleemed from anywhere open source, and my thanks go out to all those bright people who write this stuff :-)

I am running opensim from the svn (Latest build daily) thing, then compile it in visual studio it occasionally wants to update the code to 2008 vers so i let it :-) where possible i will show the author and a link :-) Any problems let me know zoon@edenrealm.co.uk copy all below the "heading" into a new script in your in-world inventory, then drag and drop into your prim..... as if you didnt know :-) Samantha can be located on Openlife grid, Oh yes, i have played with the settings a little. There are lots of sources to look at and OsGrid would be a great place to start.

Particles

// *** Fountian Particles ***
// *** by Samantha Fuller ***
// *** ver 1 for OLG alpha .5 - March 5 /08 ***
integer on;
start_particles()
{
    llParticleSystem([
    PSYS_PART_FLAGS, PSYS_PART_EMISSIVE_MASK //PSYS_PART_TARGET_POS_MASK 
    | PSYS_PART_INTERP_COLOR_MASK | PSYS_PART_INTERP_SCALE_MASK, 
//|PSYS_PART_WIND_MASK,
//PSYS_PART_FOLLOW_VELOCITY_MASK,
    PSYS_SRC_PATTERN,
// ***  Choose 1 pattern from the following ***
    // PSYS_SRC_PATTERN_EXPLODE,
       PSYS_SRC_PATTERN_DROP,
    // PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY,
    // PSYS_SRC_PATTERN_ANGLE_CONE,
    // PSYS_SRC_PATTERN_ANGLE,

    PSYS_SRC_ANGLE_BEGIN, 5.015, 
    PSYS_SRC_ANGLE_END, 10.5,
    PSYS_PART_START_SCALE, <0.1, 0.3, 0.1>,
    PSYS_PART_END_SCALE, <5.05,5.05,5.05>,
    PSYS_PART_START_ALPHA, .9,
    PSYS_PART_END_ALPHA, 0.05,
    PSYS_PART_START_COLOR, <1.0, 1.0, 1.0>,
    PSYS_PART_END_COLOR, <1.0, 0.0, 1.0>,
    PSYS_PART_MAX_AGE, 5.5,
    PSYS_SRC_ACCEL, < 0.0, 0.0, 0.2>,
    PSYS_SRC_BURST_RATE, 0.500,
    PSYS_SRC_BURST_PART_COUNT, 10,
    PSYS_SRC_BURST_RADIUS, 1.075,
    PSYS_SRC_BURST_SPEED_MAX, 2,
    PSYS_SRC_BURST_SPEED_MIN, 1,
    PSYS_SRC_TARGET_KEY, llGetKey()
    ]);
}

default
{
    state_entry()
    {
        start_particles();
        llSleep(6);
        //llParticleSystem([]);
        llWhisper(0,"particle change");
    }
 touch_start(integer touches)
    {
        if (on == 0)
        {
            on = 1;
            start_particles();
            llWhisper(0,"fountian on");
        }
        else
        {
            on = 0;
            llParticleSystem([]);
            llWhisper(0,"fountian off");
        }
    }
}

Sound loop

default
{
    state_entry()
    {
        llSetTimerEvent(9.9);
        llSay(0,"reset.");
    }
    
    timer()
    {
        llPlaySound("rightclick on your sound and copy the UUID here, with care",1.0);
    }
}

Smooth rotate texture

default
{
    state_entry()                                   
    {                                               
       float SPEED = 0.2; 
       llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, ALL_SIDES, 0, 0, 1.0, 1000, SPEED);
    }
}

Sit and position

Just drop into an object and play with the vector rot stuff and llsitTarget till happy :-)

default{

state_entry()
        {
         llSetText("sit here ", <0,1,0>,1);
         llSay(0,"started");
         vector rot=<180.0, -180.0, 0.0>*DEG_TO_RAD;
         rotation finalrot=llEuler2Rot(rot);
         llSitTarget(<-0.35, 0.0, 0.75>,finalrot);
        }
}

Rotating Prim

I think this came from Nebaden :-).....

default 
  {
    state_entry()
     {
      llSetText("put your text in here", <1,1,1>,1);
      llTargetOmega(<0,0,1>, 0.2, 2);
     }
  }

A Opensim version for llHTTPResponse

As we know, until now we receive a very nice message for llHTTPResponse :D, but to make a prim communicate to another, i've made this method:

Client

// This script is to do a request on the primitive url on the description and return it's response.
key url_request;

 string myurl; //This is only valid for internal Requests/Responses, for calling from other grids, use the simulator ip:port where it shows something like 2K3S-***-***-***:port, but mantain the rest.

integer listen_u;

string prepare_post_body(list l)
{
    integer i;
    string body;
    integer len=llGetListLength(l) & 0xFFFE; // make it even
    for (i=0;i<len;i+=2)
    {
        string varname=llList2String(l,i);
        string varvalue=llList2String(l,i + 1);
        if (i>0) body+="&";
        body+=llEscapeURL(varname)+"="+llEscapeURL(varvalue);
    }
    return body;
}

list Postdata2List(string data)
{
    return llParseString2List(data, "&", "");
}

string Httpdata2String(string data)
{
    list d = llParseString2List(data, "=", "");
    return llUnescapeURL(llList2String(d, 1));
}

key FastHttpRequest(string url, list meta, list body)
{
    return llHTTPRequest(url, meta, prepare_post_body(body));
} 

default
{
    
    state_entry()
    {
        url_request = llRequestURL();
    }
    http_request(key id, string method, string body)
    {
        if (url_request == id)
        {
            url_request = "";
            if (method == "URL_REQUEST_GRANTED")
            {
                llSetText("MyURL> " + body, <1,.5,0>, 1.0);
                myurl = body;
                state run;
            }
            else if (method == "URL_REQUEST_DENIED")
            {
                llSay(0, "Something went wrong, no url. " + body);
            }
        }
        else
        {
            llSay(0, "Received> " + body);
        }
    }
}

state run
{
    state_entry()
    {
        llSay(0, "Running, touch for request to my description.");
        listen_u = llListen(-1, "", "", "");
        llListen(1, "", "", "reset");
    }
    
    listen(integer c, string n, key k, string m)
    {
        if(c == -1)
        {
            llListenRemove(listen_u);
            llSetObjectDesc(m);
        }
        if(c == 1 && m == "reset")
        {
            llResetScript();
        }
    }
    
    touch_start(integer i)
    {
        FastHttpRequest(llGetObjectDesc(), [HTTP_METHOD, "POST",HTTP_MIMETYPE, "application/x-www-form-urlencoded"],["MYURL",myurl,"MESSAGE","Hello, my name is " + llGetObjectName() + "."]);
    }

    http_request(key id, string method, string body)
    {
        if (url_request == id)
        {
            url_request = "";
            if (method == "URL_REQUEST_GRANTED")
            {
                llSetText("MyURL> " + body, <1,.5,0>, 1.0);
                myurl = body;
            }
            else if (method == "URL_REQUEST_DENIED")
            {
                llSay(0, "Something went wrong, no url. " + body);
            }
        }
        else
        {
            list body_i = Postdata2List(body);
            string url = Httpdata2String(llList2String(body_i,0));
            string data = Httpdata2String(llList2String(body_i,1));
            llSay(0, "Received> " + data);
        }
    }
}

Server

key url_request;
 
 string myurl;//This is only valid for internal Requests/Responses, for calling from other grids, use the simulator ip:port where it shows something like 2K3S-***-***-***:port, but mantain the rest.
 
string prepare_post_body(list l)
{
    integer i;
    string body;
    integer len=llGetListLength(l) & 0xFFFE; // make it even
    for (i=0;i<len;i+=2)
    {
        string varname=llList2String(l,i);
        string varvalue=llList2String(l,i + 1);
        if (i>0) body+="&";
        body+=llEscapeURL(varname)+"="+llEscapeURL(varvalue);
    }
    return body;
} 
 
list Postdata2List(string data)
{
    return llParseString2List(data, "&", "");
}

string Httpdata2String(string data)
{
    list d = llParseString2List(data, "=", "");
    return llUnescapeURL(llList2String(d, 1));
}
 
key FastHttpRequest(string url, list meta, list body)
{
    return llHTTPRequest(url, meta, prepare_post_body(body));
} 
 
default
{
    state_entry()
    {
        url_request = llRequestURL();
    }
    touch_start(integer i)
    {
//        llSay(0, "URL: " + myurl);
//        
//        llSay(-1, myurl);
        
        llSetText(" ", <0,0,0>, 0.0);
        
        llResetScript();
    }
    http_request(key id, string method, string body)
    {
        if (url_request == id)
        {
            url_request = "";
            if (method == "URL_REQUEST_GRANTED")
            {
                llSay(0,"New URL: " + body);
                
                llSay(-1, body);
                myurl = body;
            }
            else if (method == "URL_REQUEST_DENIED")
            {
                llSay(0, "Something went wrong, no url. " + body);
            }
        }
        else
        {
//            llSay(0, body);
            list body_i = Postdata2List(body);
            string url = Httpdata2String(llList2String(body_i,0));
            string data = Httpdata2String(llList2String(body_i,1));
            llSetText("FROM: " + url + "\nDATA: " + data, <1,.5,0>, 1.0);
//            llSay(0, "FROM: " + url + "\nDATA: " + data);
//            llHTTPResponse(id, 200, body);
            llSay(0, "Response to " + url);
            FastHttpRequest(url, [HTTP_METHOD, "POST",HTTP_MIMETYPE, "application/x-www-form-urlencoded"], ["MYURL", myurl, "MESSAGE", "You sent me: \""+data+"\""]);
            llSay(0, "Sent!");
        }
    }
}

To receive a response, you need to send in the body this parameter: MYURL and in value add the object url, but if you need, try to change the value of url to the ip:port of region, sometimes it may be strange. Is it, easy? ;D

Will keep updating until told otherwise :-)