Difference between revisions of "User:Opensource Obscure/FFHUD"
m |
(0.6.1) |
||
Line 2: | Line 2: | ||
== FFHUD: a simple FriendFeed HUD == | == FFHUD: a simple FriendFeed HUD == | ||
'''v 0.6 by [[User:Opensource_Obscure|Opensource Obscure]] '''<br> | '''v 0.6.1 by [[User:Opensource_Obscure|Opensource Obscure]] '''<br> | ||
this code is probably horrible and flawed<br> | this code is probably horrible and flawed<br> | ||
Line 38: | Line 38: | ||
string user=""; // your FriendFeed username | string user=""; // your FriendFeed username | ||
string ffkey=""; // your FriendFeed key | string ffkey=""; // your FriendFeed key | ||
string baseurl="@friendfeed.com/api/share"; | string baseurl="@friendfeed.com/api/share"; | ||
string text; | string text; | ||
Line 44: | Line 44: | ||
string message; | string message; | ||
string desc; | string desc; | ||
key texturedefault = "632f82da-7be7-9c7a-f254-3fc41a36ae12"; | |||
azzera() | azzera() | ||
{ | { | ||
llSetTexture(texturedefault, ALL_SIDES); | |||
text=""; | text=""; | ||
url=""; | url=""; | ||
Line 52: | Line 54: | ||
desc = ""; | desc = ""; | ||
} | } | ||
string strReplace(string source, string pattern, string replace) { | string strReplace(string source, string pattern, string replace) { | ||
while (llSubStringIndex(source, pattern) > -1) { | while (llSubStringIndex(source, pattern) > -1) { | ||
Line 64: | Line 66: | ||
return source; | return source; | ||
} | } | ||
string regionname() | string regionname() | ||
{ | { | ||
Line 71: | Line 73: | ||
return region; | return region; | ||
} | } | ||
string parcelname() | string parcelname() | ||
{ | { | ||
Line 80: | Line 82: | ||
return name; | return name; | ||
} | } | ||
string parceldesc() | string parceldesc() | ||
{ | { | ||
Line 96: | Line 98: | ||
return desc; | return desc; | ||
} | } | ||
string slurl() | string slurl() | ||
{ | { | ||
Line 110: | Line 112: | ||
return url; | return url; | ||
} | } | ||
default | default | ||
{ | { | ||
state_entry() | state_entry() | ||
{ | { | ||
azzera(); | azzera(); | ||
llListen(8, "", llGetOwner(), ""); | llListen(8, "", llGetOwner(), ""); | ||
} | } | ||
touch_start(integer total_number) | touch_start(integer total_number) | ||
{ | { | ||
Line 124: | Line 126: | ||
llMessageLinked(2, 1, "", NULL_KEY); | llMessageLinked(2, 1, "", NULL_KEY); | ||
} | } | ||
listen(integer channel, string name, key id, string message) | listen(integer channel, string name, key id, string message) | ||
{ | { | ||
Line 133: | Line 135: | ||
text = strReplace(text,"&","and"); | text = strReplace(text,"&","and"); | ||
} | } | ||
link_message(integer sender_num, integer num, string str, key id) | link_message(integer sender_num, integer num, string str, key id) | ||
{ | { | ||
Line 156: | Line 158: | ||
"&image0_url=" + | "&image0_url=" + | ||
llEscapeURL(imageurl); | llEscapeURL(imageurl); | ||
llHTTPRequest(post, [HTTP_METHOD,"POST"], ""); | llHTTPRequest(post, [HTTP_METHOD,"POST"], ""); | ||
} | } | ||
http_response(key request_id, integer status, list metadata, string body) | http_response(key request_id, integer status, list metadata, string body) | ||
{ | { | ||
Line 167: | Line 168: | ||
} | } | ||
} | } | ||
} | } | ||
</lsl> | </lsl> | ||
Line 185: | Line 184: | ||
** resident or group that owns it | ** resident or group that owns it | ||
** how many people are around you right now, their names and a link you can click to directly open their profile | ** how many people are around you right now, their names and a link you can click to directly open their profile | ||
*** this scan uses a default radius of 96 meters; change scanradius in the 1st line of script as needed | |||
* receives linkedmessages from script 1 | * receives linkedmessages from script 1 | ||
* retrieves from web the profile image texture UUID for resident or group that owns the parcel you're in | * retrieves from web the profile image texture UUID for resident or group that owns the parcel you're in | ||
Line 191: | Line 191: | ||
<lsl> | <lsl> | ||
float scanradius = 96.0; | |||
string ownerurl = "http://world.secondlife.com/resident/"; | string ownerurl = "http://world.secondlife.com/resident/"; | ||
string groupurl = "http://world.secondlife.com/group/"; | string groupurl = "http://world.secondlife.com/group/"; | ||
Line 196: | Line 197: | ||
string code2 = "\" class=\"parcelimg\" />"; | string code2 = "\" class=\"parcelimg\" />"; | ||
key texturedefault = "19920f4f-d667-ab18-7234-af4623b52065"; | key texturedefault = "19920f4f-d667-ab18-7234-af4623b52065"; | ||
key textureuuid = ""; | |||
string desc; | string desc; | ||
integer check; | |||
string parcelname() | string parcelname() | ||
{ | { | ||
Line 206: | Line 208: | ||
return name; | return name; | ||
} | } | ||
string parceldesc() | string parceldesc() | ||
{ | { | ||
Line 222: | Line 224: | ||
return desc; | return desc; | ||
} | } | ||
string parcelowner() | string parcelowner() | ||
{ | { | ||
Line 230: | Line 232: | ||
return uuid; | return uuid; | ||
} | } | ||
string parcelgroup() | string parcelgroup() | ||
{ | { | ||
Line 240: | Line 242: | ||
texture() | |||
{ | |||
string a = parcelgroup(); | |||
if(a == "00000000-0000-0000-0000-000000000000") | |||
{ | |||
llHTTPRequest( ownerurl + parcelowner(),[HTTP_METHOD,"GET"],""); | |||
} | |||
else | |||
{ | |||
llHTTPRequest( groupurl + parcelgroup(),[HTTP_METHOD,"GET"],""); | |||
} | |||
} | |||
infoparcel() | infoparcel() | ||
{ | { | ||
Line 248: | Line 263: | ||
llSensor("", NULL_KEY, AGENT, scanradius, PI); | llSensor("", NULL_KEY, AGENT, scanradius, PI); | ||
} | } | ||
default | default | ||
{ | { | ||
Line 256: | Line 271: | ||
llSetTexture(texturedefault, ALL_SIDES); | llSetTexture(texturedefault, ALL_SIDES); | ||
} | } | ||
link_message(integer sender_num, integer num, string str, key id) | link_message(integer sender_num, integer num, string str, key id) | ||
{ | { | ||
check = TRUE; | |||
textureuuid = "88745b46-da05-11d5-8ac0-0003477c4611"; | |||
texture(); | |||
} | } | ||
touch_start(integer total_number) | touch_start(integer total_number) | ||
{ | { | ||
check = FALSE; | |||
infoparcel(); | infoparcel(); | ||
texture(); | |||
} | } | ||
http_response(key req,integer stat, list met, string body) | http_response(key req,integer stat, list met, string body) | ||
{ | { | ||
textureuuid = (key)llGetSubString(body,llSubStringIndex(body, code1)+llStringLength(code1),llSubStringIndex(body,code2)-3); | |||
llSetTexture( | llSetTexture(textureuuid, ALL_SIDES); | ||
llMessageLinked(1, 2, "", | if (check == TRUE) | ||
{ | |||
llMessageLinked(1, 2, "", textureuuid); | |||
} | |||
} | } | ||
sensor(integer total_number) | sensor(integer total_number) | ||
{ | { | ||
Line 295: | Line 308: | ||
llOwnerSay(llDetectedName(i) + " > secondlife:///app/agent/" + (string)llDetectedKey(i) + "/about"); | llOwnerSay(llDetectedName(i) + " > secondlife:///app/agent/" + (string)llDetectedKey(i) + "/about"); | ||
} | } | ||
} | } | ||
no_sensor() | no_sensor() | ||
Line 301: | Line 314: | ||
llOwnerSay("nobody here right now (radius=" + (string)scanradius + " meters)"); | llOwnerSay("nobody here right now (radius=" + (string)scanradius + " meters)"); | ||
} | } | ||
} | } | ||
</lsl> | </lsl> |
Revision as of 10:37, 13 June 2008
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
FFHUD: a simple FriendFeed HUD
v 0.6.1 by Opensource Obscure
this code is probably horrible and flawed
use of this script may be a violation of ToS - help to clearify this is welcome :)
How it works
- edit script 1 with your FriendFeed account data
- put script 1 in a prim
- put script 2 in another prim
- link the prims
- wear the object as an HUD
________ | | | | 1 | 2 | |___|___|
- touch button 2 to get info about the parcel you're in and agents around
- touch button 1 to publish a post on FriendFeed that includes available info about the parcel (SLURL, name, description, owner/owner group profile image if available)
- say a message on channel 8 to publish a post on FriendFeed with parcel info + your message:
/8 This is my message
script 1/2: FFHUD
This script:
- accepts touch event
- listens on channel 8 for your message
- sends a linkedmessage to script 2 (upon touch event or message on channel 8)
- receives texture uuid from script 2 via linkedmessage
- sends http request to friendfeed (after the linkedmessage from script 2)
<lsl>
// your FriendFeed username are here: https://friendfeed.com/account/api string user=""; // your FriendFeed username string ffkey=""; // your FriendFeed key
string baseurl="@friendfeed.com/api/share"; string text; string url; string message; string desc; key texturedefault = "632f82da-7be7-9c7a-f254-3fc41a36ae12";
azzera() {
llSetTexture(texturedefault, ALL_SIDES); text=""; url=""; message=""; desc = "";
}
string strReplace(string source, string pattern, string replace) {
while (llSubStringIndex(source, pattern) > -1) { integer len = llStringLength(pattern); integer pos = llSubStringIndex(source, pattern); if (llStringLength(source) == len) { source = replace; } else if (pos == 0) { source = replace+llGetSubString(source, pos+len, -1); } else if (pos == llStringLength(source)-len) { source = llGetSubString(source, 0, pos-1)+replace; } else { source = llGetSubString(source, 0, pos-1)+replace+llGetSubString(source, pos+len, -1); } } return source;
}
string regionname()
{
string region=llDumpList2String(llParseString2List(llGetRegionName(),[" "],[]),"+"); return region;
}
string parcelname() {
list lstParcelName=llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_NAME]); string a = (string)lstParcelName; string name = llDumpList2String(llParseString2List(a,[" "],[]),"+"); name = strReplace(name,"&","and"); return name;
}
string parceldesc() {
list lstParcelDesc=llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_DESC]); string a = (string)lstParcelDesc; if(a != "00000000-0000-0000-0000-000000000000") { desc = llDumpList2String(llParseString2List(a,[" "],[]),"+"); } else { desc = ""; } desc = strReplace(desc,"&","and"); return desc;
}
string slurl() {
string simname = llDumpList2String(llParseString2List(llGetRegionName(),[" "],[]),"+"); string regionname = simname; vector detectedPos = llGetRootPosition(); string sx = (string)llRound(detectedPos.x); string sy = (string)llRound(detectedPos.y); string sz = (string)llRound(detectedPos.z); string url = "http://slurl.com/secondlife/"; url += simname; url += "/" + sx + "/" + sy + "/" + sz ; return url;
}
default {
state_entry() { azzera(); llListen(8, "", llGetOwner(), ""); } touch_start(integer total_number) { azzera(); llMessageLinked(2, 1, "", NULL_KEY); } listen(integer channel, string name, key id, string message) { azzera(); llMessageLinked(2, 1, "", NULL_KEY); text = "+-+MY MESSAGE:+" + message; text = strReplace(text,"&","and"); } link_message(integer sender_num, integer num, string str, key id) { string imageurl = "http://secondlife.com/app/image/" + (string)id + "/2"; text = llDumpList2String(llParseString2List(text,[" "],[]),"+"); string post = "http://" + user + ":" + ffkey + baseurl + "?title=" + regionname() + "+-+" + parcelname() + "&link=" + llEscapeURL(slurl()) + "&comment=" + "PARCEL+INFO:+" + parceldesc() + text + "&image0_url=" + llEscapeURL(imageurl); llHTTPRequest(post, [HTTP_METHOD,"POST"], ""); } http_response(key request_id, integer status, list metadata, string body) { { llOwnerSay("Message sent to http://friendfeed.com/" + user); } }
}
</lsl>
script 2/2: PARCEL INFO
This script:
- accepts touch event
- gives info via chat about the parcel you're in:
- name
- description
- resident or group that owns it
- how many people are around you right now, their names and a link you can click to directly open their profile
- this scan uses a default radius of 96 meters; change scanradius in the 1st line of script as needed
- receives linkedmessages from script 1
- retrieves from web the profile image texture UUID for resident or group that owns the parcel you're in
- sends texture UUID to script 1
<lsl>
float scanradius = 96.0; string ownerurl = "http://world.secondlife.com/resident/"; string groupurl = "http://world.secondlife.com/group/"; string code1 = "<img alt=\"profile image\" src=\"http://secondlife.com/app/image/"; string code2 = "\" class=\"parcelimg\" />"; key texturedefault = "19920f4f-d667-ab18-7234-af4623b52065"; key textureuuid = ""; string desc; integer check;
string parcelname() {
list lstParcelName=llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_NAME]); string a = (string)lstParcelName; string name = llDumpList2String(llParseString2List(a,[" "],[]),"+"); return name;
}
string parceldesc()
{
list lstParcelDesc=llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_DESC]); string a = (string)lstParcelDesc; if(a != "00000000-0000-0000-0000-000000000000") { desc = llDumpList2String(llParseString2List(a,[" "],[]),"+") + "+-+"; } else { desc = ""; } return desc;
}
string parcelowner()
{
list lstParcelOwner=llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_OWNER]); string uuid = (string)lstParcelOwner; return uuid;
}
string parcelgroup()
{
list lstParcelGroup=llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_GROUP]); string uuid = (string)lstParcelGroup; return uuid;
}
texture()
{
string a = parcelgroup(); if(a == "00000000-0000-0000-0000-000000000000") { llHTTPRequest( ownerurl + parcelowner(),[HTTP_METHOD,"GET"],""); } else { llHTTPRequest( groupurl + parcelgroup(),[HTTP_METHOD,"GET"],""); }
}
infoparcel() {
llOwnerSay("parcel name =" + parcelname()); llOwnerSay("parcel desc =" + parceldesc()); llOwnerSay("parcel owner = " + "secondlife:///app/agent/" + parcelowner() + "/about"); llOwnerSay("parcel group = " + "secondlife:///app/group/" + parcelgroup() + "/about"); llSensor("", NULL_KEY, AGENT, scanradius, PI);
}
default
{
state_entry() { llSetTexture(texturedefault, ALL_SIDES); } link_message(integer sender_num, integer num, string str, key id) { check = TRUE; textureuuid = "88745b46-da05-11d5-8ac0-0003477c4611"; texture(); }
touch_start(integer total_number) { check = FALSE; infoparcel(); texture(); } http_response(key req,integer stat, list met, string body) { textureuuid = (key)llGetSubString(body,llSubStringIndex(body, code1)+llStringLength(code1),llSubStringIndex(body,code2)-3); llSetTexture(textureuuid, ALL_SIDES); if (check == TRUE) { llMessageLinked(1, 2, "", textureuuid); } } sensor(integer total_number) { llOwnerSay((string)total_number + " avatar" + " in " + (string)scanradius+ " meters"); integer i; for (i = 0; i < total_number; i++) { llOwnerSay(llDetectedName(i) + " > secondlife:///app/agent/" + (string)llDetectedKey(i) + "/about"); } } no_sensor() { llOwnerSay("nobody here right now (radius=" + (string)scanradius + " meters)"); }
}
</lsl>