Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Location of a Avatar

Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
10-04-2009 13:37
I have been playing with a security script I made many moons ago and would like to have it now so it only looks at the parcel the security system is on. I have spent a ton of time today looking over the wiki and reading but still have some questions I couldn't find an answer to there. Now like many security systems mine pulls a "allowed" list from either a list in the script or a nc(as I have wrote it both ways). When it compares the detected name to that of the list it then knows what to do. My question is, when I check the name to the list I also want to be able to check the location of the detected to make sure they are over the parcel the system is on. I know you can use llGetObjectDetails and other methods of getting the location of the detected avatar, but how would I compare that to the parcel location to make sure they are either on or off the parcel. This is what has be confused at the moment.

The overall idea is to only have the security work if they are on xyz parcel and not interfere with those that might be in range of the security system but on another parcel.

Hope I made this all clear so you can understand. And thanks in advance for any info to help me figure this out.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
10-04-2009 13:54
I obviously don't know the structure of your script, but couldn't you use

if (llOverMyLand(llDetectedKey(0))){//Do stuff} ?
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Indeterminate Schism
Registered User
Join date: 24 May 2008
Posts: 236
10-04-2009 14:17
If Rollig's suggestion isn't sufficient you should probably look at http://wiki.secondlife.com/wiki/LlGetParcelDetails.

In your sensor loop use something like ...
if(llGetParcelDetails(llGetPos(), PARCEL_DETAILS_NAME) == llGetParcelDetails(llDetectedPos(n), PARCEL_DETAILS_NAME))

Using the other details that the function can return means you can make a sensor that works across disjointed areas, for example. Description can be fun for things you'd LIKE to have active on this parcel, so the same scanner could cover two different parcels, say, with the action to take for each one determined by a code in the parcel description.
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
10-04-2009 22:17
From: Indeterminate Schism
If Rollig's suggestion isn't sufficient you should probably look at http://wiki.secondlife.com/wiki/LlGetParcelDetails.

In your sensor loop use something like ...
if(llGetParcelDetails(llGetPos(), PARCEL_DETAILS_NAME) == llGetParcelDetails(llDetectedPos(n), PARCEL_DETAILS_NAME))

Using the other details that the function can return means you can make a sensor that works across disjointed areas, for example. Description can be fun for things you'd LIKE to have active on this parcel, so the same scanner could cover two different parcels, say, with the action to take for each one determined by a code in the parcel description.



This is what I was looking for, I didnt want the llOverMyLand because it requires it to be deeded.

Looking at the response above,
if(llGetParcelDetails(llGetPos(), PARCEL_DETAILS_NAME) == llGetParcelDetails(llDetectedPos(n), PARCEL_DETAILS_NAME))
I dont quite understand how that is working though. Unless what I think is correct, the first part is getting the objects pos and parcel name it is on then compairing it to the second that is getting the detected avatars pos and parcel name it is on.

Could someone verify I am understanding this correctly please.

Thanx
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
10-04-2009 22:36
That's right. You are testing to see whether the detected avatar is in the same parcel that your detector is.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
10-04-2009 23:11
Thank you everyone for the advice and Rolig for letting me know I was understanding it correctly.

Now to make it work in my script, lol!

Thanx
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
10-04-2009 23:47
OK, not sure what I am missing here but it still ejects the avatar even after they leave the parcel. I posted the sensor code below, maybe someone can see what I am missing or have done wrong. I hate when I spend an afternoon reading and all and still cant make it work like I was wanting, probably something small I am just not seeing, lol

From: someone

sensor( integer number_detected )
{
integer i;
for( i = 0; i < number_detected; i++ )
{
if( llDetectedKey( i ) != llGetOwner() )
{
string detected_name = llDetectedName( i );
ejected = detected_name;
if( allowed_list( detected_name ) == FALSE && llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME]) == llGetParcelDetails(llDetectedPos(i), [PARCEL_DETAILS_NAME]))
{
llDialog(llDetectedKey(i), "" + llKey2Name(detected_name) + ", you are in an unauthorized are, please leave within 10 seconds or be ejected.",["Ok"],5781);
names+=ejected;
llSleep(10);

if(llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME]) == llGetParcelDetails(llDetectedPos(n), [PARCEL_DETAILS_NAME]))
{
llEjectFromLand(llDetectedKey(i));

}
}
}
}
}
ab Vanmoer
Registered User
Join date: 28 Nov 2006
Posts: 131
10-05-2009 01:33
The sensor event detects an avatar and its position when the event is fired, it doesn't continue to track the avatar. So your second call to llDetectedPos will return the same position as the first and should instead be replaced with llGetObjectDetails to get an updated position.

Also, you have a few typos, your second call to llDetectedPos has a parameter of 'n', not 'i'. In the llDialog call, you are trying to get a name from a name with llKey2Name.

For efficiency and less chance of errors, you might want to assign the result of function calls to variables if you are calling the same functions more than once.
eg.
From: someone

key owner=llGetOwner();
key detected=llDetectedKey( i );
string detected_name = llDetectedName( i );
string ps=llList2String(llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME]),0);
string pa=llList2String(llGetParcelDetails(llDetectedPos(i), [PARCEL_DETAILS_NAME]),0);

If the return from a function call is only used once, it is probably slightly less efficient to assign it to a variable, but it can make the code cleaner and easier to read especially if one is learning LSL.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
10-05-2009 10:23
Sound advice from Ab. Another thing to note: you can't actually tell with 100% certainty whether two points (not in the same 4mx4m square) are on the same parcel. You can use some of the details about the parcel to try to figure it out (i.e. compare parcel owner, parcel name, and other parcel details), but it is quite possible to have two parcels with all the same details (as seen in LSL). It would be very nice, and has been suggested for a long time but never implemented, if we simply had a function to retrieve the coordinates of the far North-West corner of the parcel under a certain point, or something like that. That would give us a true parcel ID (since each 4mx4m square belongs to one and only one parcel).

That being said, you can carefully manage your parcels using a scheme that allows you to distinguish them (for example, make sure no two parcels you own in a region have the same name). So the design of your script and the land management process you use have to be carefully aligned. Be especially diligent when you split parcels, as that makes it easy to come up with two that have the same details.
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
10-05-2009 19:44
OK, after listening to what everyone said I did it a little different than what was planned. What I ended up doing was when it scanned and detected an user it gave them a warning, waited 10 seconds, then goes to a second scan state that checks if they are still in range and if so it ejects them, if not, it goes back to the default scan state and scans as normal.

Thanks everyone for the advice and info!!