Get Profile Picture: Difference between revisions
Jump to navigation
Jump to search
m *fixed a few errors after compiling in-world* |
optimisation of parameters |
||
| Line 8: | Line 8: | ||
// Get Profile Picture by Valentine Foxdale | // Get Profile Picture by Valentine Foxdale | ||
// optmisation by SignpostMarv Martin | |||
list sides; | list sides; | ||
list deftextures; | list deftextures; | ||
integer s1l; // calculated from profile_key_prefix in state_entry() | |||
string profile_key_prefix = "<img alt=\"profile image\" src=\"http://secondlife.com/app/image/"; | |||
string profile_key_suffix = "\" class=\"parcelimg\" />"; | |||
GetProfilePic(key id) //Run the HTTP Request then set the texture | GetProfilePic(key id) //Run the HTTP Request then set the texture | ||
{ | { | ||
| Line 41: | Line 45: | ||
state_entry() | state_entry() | ||
{ | { | ||
s1l = llStringLength(profile_key_prefix); | |||
llSetText("Touch for this object to display your profile picture!",<0.8,0,1>,1); //Note: Usage of another person's profile picture without their permission may be viewed as copyright infringement. | llSetText("Touch for this object to display your profile picture!",<0.8,0,1>,1); //Note: Usage of another person's profile picture without their permission may be viewed as copyright infringement. | ||
GetDefaultTextures(); | GetDefaultTextures(); | ||
| Line 50: | Line 55: | ||
http_response(key req,integer stat, list met, string body) | http_response(key req,integer stat, list met, string body) | ||
{ | { | ||
integer s1 = llSubStringIndex(body, | integer s1 = llSubStringIndex(body,profile_key_prefix); | ||
integer s2 = llSubStringIndex(body,profile_key_suffix)-3; | |||
integer s2 = llSubStringIndex(body, | |||
if(s1 == -1){SetDefaultTextures();} | if(s1 == -1){SetDefaultTextures();} | ||
else | else | ||
Revision as of 04:16, 27 April 2009
| LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Get Profile Picture by Valentine Foxdale
<lsl>
// Snippets and HTTPRequest bits were taken from:
//~ RANDOM PROFILE PROJECTOR v5.4.5 by Debbie Trilling ~
// Get Profile Picture by Valentine Foxdale // optmisation by SignpostMarv Martin list sides; list deftextures; integer s1l; // calculated from profile_key_prefix in state_entry() string profile_key_prefix = "<img alt=\"profile image\" src=\"http://secondlife.com/app/image/"; string profile_key_suffix = "\" class=\"parcelimg\" />"; GetProfilePic(key id) //Run the HTTP Request then set the texture {
//key id=llDetectedKey(0); This breaks the function, better off not used //string URL_RESIDENT = "http://world.secondlife.com/resident/"; doesn't work anymore, replace with: string URL_RESIDENT = "http://world.secondlife.com/a/resident/"; llHTTPRequest( URL_RESIDENT + (string)id,[HTTP_METHOD,"GET"],"");
} GetDefaultTextures() //Get the default textures from each side {
integer i;
integer faces = llGetNumberOfSides();
for (i = 0; i < faces; i++)
{
sides+=i;
deftextures+=llGetTexture(i);
}
} SetDefaultTextures() //Set the sides to their default textures {
integer i;
integer faces;
faces = llGetNumberOfSides();
for (i = 0; i < faces; i++)
{
llSetTexture(llList2String(deftextures,i),i);
}
} default {
state_entry()
{
s1l = llStringLength(profile_key_prefix);
llSetText("Touch for this object to display your profile picture!",<0.8,0,1>,1); //Note: Usage of another person's profile picture without their permission may be viewed as copyright infringement.
GetDefaultTextures();
}
touch_start(integer total_number)
{
GetProfilePic(llDetectedKey(0));
}
http_response(key req,integer stat, list met, string body)
{
integer s1 = llSubStringIndex(body,profile_key_prefix);
integer s2 = llSubStringIndex(body,profile_key_suffix)-3;
if(s1 == -1){SetDefaultTextures();}
else
{
key UUID=llGetSubString(body,s1+s1l,s2);
llSetTexture(UUID,ALL_SIDES);
}
}
} </lsl>