User:Dzonatas Sol/HttpCastRayLLSD
Jump to navigation
Jump to search
<lsl> default {
state_entry()
{
llSay(0, "Rebooted.");
llRequestURL();
}
http_request(key id, string method, string body)
{
if (method == URL_REQUEST_GRANTED)
{
llSay(0,"URL: " + body);
}
else if (method == URL_REQUEST_DENIED)
{
llSay(0, "Something went wrong, no url. " + body);
}
else if (method == "GET")
{
string query = llGetHTTPHeader(id, "x-query-string");
list qvar = llParseString2List(query, ["filter=", "&sx=", "&sy=","&sz=","&ex=", "&ey=","&ez="], [""]);
integer filter = (integer)llList2String(qvar, 0);
float x = (float)llList2String(qvar, 1);
float y = (float)llList2String(qvar, 2);
float z = (float)llList2String(qvar, 3);
vector start = <x,y,z> ;
x = (float)llList2String(qvar, 4);
y = (float)llList2String(qvar, 5);
z = (float)llList2String(qvar, 6);
vector end = <x,y,z> ;
llSay(0, (string)start + " " + (string)end) ;
list results = llCastRay( start, end, filter, 0 ) ;
key uuid = llList2Key(results, 0);
string vec = llList2String(results, 1);
list box = llGetBoundingBox(uuid);
vector center = (llList2Vector(box, 0) + llList2Vector(box, 1)) * 0.5;
vector size = llList2Vector(box, 1) - llList2Vector(box, 0);
string text ;
text += "<llsd><map>" ;
text += "<key>ID</key>" ;
text += "<string>" + (string)uuid + "<string>" ;
text += "<key>Point</key>" ;
text += "<string>" + (string)vec + "<string>" ;
text += "<key>Center</key>" ;
text += "<string>" + (string)center + "<string>" ;
text += "<key>Size</key>" ;
text += "<string>" + (string)size + "<string>" ;
text += "</map></llsd>" ;
llHTTPResponse(id,200, text );
}
else
{
llHTTPResponse(id,405,"Unsupported Method");
}
}
} </lsl>