Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: Get optimal parcel pos for sensor

Ezian Ecksol
Unregistered User
Join date: 25 Dec 2007
Posts: 82
06-24-2008 06:06
// Get optimal parcel position for sensor at ground.
// (c) Ezian Ecksol. Use, modify, steal or sale as you like. Keep credits.

float detect_range = 96.;

string getparcelname(vector p) {
return llList2String(llGetParcelDetails(p, [PARCEL_DETAILS_NAME]),0);
}

string Float2String(float num) {
list s = llParseString2List((string)(llRound(num*10.)/10.), ["."], []);
return llList2String(s, 0)+"."+llGetSubString(llList2String(s, 1), 0, 0);
}

string Vector2String(vector v) {
return "<"+Float2String(v.x)+", "+Float2String(v.y)+", "+Float2String(v.z)+">";
}

getparcelbounds() {
vector pos = llGetPos();
vector rpos;
pos = <llRound(pos.x), llRound(pos.y), 0.>;
string name = getparcelname(pos);
vector parcel0; vector parcel1;
vector parcel_center; vector parcel_size;

rpos = pos;
do { rpos.x -= 1.; } while (getparcelname(rpos) == name);
parcel0.x = rpos.x + 1.;

rpos = pos;
do { rpos.y -= 1.; } while (getparcelname(rpos) == name);
parcel0.y = rpos.y + 1.;

rpos = pos;
do { rpos.x += 1.; } while (getparcelname(rpos) == name);
parcel1.x = rpos.x;

rpos = pos;
do { rpos.y += 1.; } while (getparcelname(rpos) == name);
parcel1.y = rpos.y;

parcel_center = (parcel1 + parcel0) / 2.;
parcel_size = parcel1 - parcel0;
float c = llPow(parcel_size.x/2.,2.)+llPow(parcel_size.y/2.,2.);
float d = detect_range*detect_range;
if (c > d)
llOwnerSay("Your parcel is to large to be covered by a "+Float2String(detect_range)+"-m-scanner. Place the detector in the middle of the parcel at ground, but the corners are not covered.";);
else {
vector dest = <parcel_center.x, parcel_center.y, llGround(parcel_center-llGetPos())+llSqrt(d-c)>;
llOwnerSay("For optimal scanning range at ground, set position of sensor object to: "+Vector2String(dest));
}
}


default {
state_entry() {
getparcelbounds();
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Library bump
06-26-2008 12:17
:)
_____________________
i've got nothing. ;)
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
06-26-2008 13:06
This any different than /54/4b/266868/1.html ?
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
06-26-2008 13:16
Nope, only difference is this one is easily found from within the scripting library.
_____________________
i've got nothing. ;)
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
06-26-2008 13:18
/me sighs. Is it Friday yet?

<--- newbie!

:rolleyes:
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
06-26-2008 17:42
From: Meade Paravane
/me sighs. Is it Friday yet?

<--- newbie!

:rolleyes:


Hang in there! Only 3-1/4 more hours for me:)
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum