I am trying to figure out how to detect if an avatar X and Y location is within an L shaped area. I've seen it done before but curious on how this is being done. list protect_x = [233.365100,223.688900,223.688900,228.208000,228.208000,233.365100];
list protect_y = [214.940700,214.940700,208.975000,208.975000,204.834500,204.834500];
vector getPos(key owner)
{
vector pos = llList2Vector(llGetObjectDetails(owner, [OBJECT_POS]),0);
return pos;
}
default
{
touch_start(integer total_number)
{
key id = llDetectedKey(0);
vector pos = getPos(id);
llOwnerSay("Your current position: "+(string)pos);
float x = (float)pos.x;
float y = (float)pos.y;
llOwnerSay("X: "+(string)x+" Y: "+(string)y);
integer len = llGetListLength(protect_x);
integer i = 0;
integer j = 1;
integer G = FALSE;
while (j < len)
{
if (x > llList2Float(protect_x,i) && x < llList2Float(protect_x,j) && y > llList2Float(protect_y,i) && y < llList2Float(protect_y,j))
{
G=TRUE;
}
++i;
++j;
}
if (G == TRUE) { llSay(0,"You're in protected area");} else { llSay(0,"You're not in protected area");}
}
} The area is an L shaped area. Just really hung up on this one :\